Japanese Prime Minister Yasuhiro Nakasone paid a harmonious visit to President Reagan yesterday to prepare for this weekend's Williamsburg summit meeting and to discuss U.S.-Japan relations, which both sides described as improving.

Both at the White House and in a subsequent commencement address at Johns Hopkins University, Nakasone expressed his backing for an early summit meeting between Reagan and Soviet leader Yuri V. Andropov even though on Thursday Reagan was notably unenthusiastic, telling reporters there is no evidence that Andropov is ready for such a meeting. Reagan said that it "makes no sense" to raise the hopes of the world unless positive results are likely to flow from such a meeting.

Part of the harmony between the two leaders stemmed from their statements, and those of their official briefers, which minimized the continuing differences between the two countries and emphasized the remedial steps toward broader agreement since Nakasone's first trip here as prime minister four months ago.

Another element of harmony was provided by the U.S. Army chorus, which sang "Otanjobi Omedeto," Happy Birthday rendered in Japanese. Reagan also produced a cake for Nakasone's 65th birthday to top off a White House working luncheon.

Later Nakasone was presented with another cake by students at the Johns Hopkins School of Advanced International Studies, where he delivered the commencement address in English, an unusual feat for a Japanese political leader.

Nakasone, whose popularity at home has suffered from his military policies and reputation as a hawk, said little or nothing of the plans to improve Japan's military responsibility and resources that were outlined during his January trip to Washington. According to White House and Japanese official briefings, Reagan also did not dwell on military questions in the meeting yesterday.

"We weren't there pressing for new things" on the military side, said the White House briefer.

U.S. officials expressed the view that Japan under Nakasone's leadership is moving toward a more substantial military role, within the constraints of the Japanese budget and "peace constitution." The U.S. officials were also aware of Nakasone's sensitive political situation in the military field.

On the economic side, U.S. Cabinet members brought up Japan's non-tariff barriers, Washington's drive for more U.S. sales to Nippon Telephone and Telegraph Company and the problems posed by Japan's "industrial policy," which sometimes features highly organized drives aimed at securing a strong national position in targeted industries.

However, the official briefers did not indicate that Reagan or his Cabinet members pressed Nakasone for specific new steps in the economic field. For his part, the Japanese leader said at the White House, according to a Japanese briefing, that bilateral issues with the United States are "being taken care of" through consultations among experts.

Japanese briefers said Reagan, at the White House luncheon, described U.S.-Japanese relations since Nakasone's January visit as "active and constructive."

Nakasone, speaking before cameras and reporters as he left the White House, said that the relationship between the United States and Japan had progressed since his last visit. He maintained that "any issue between our two countries can be solved through prompt and reasonable consultation between us."