The tale is told of a Japanese Rip Van Winkle, who, having entered his slumber in the dark, final days of World War II, awakens in modern Tokyo. He gazes dumbstruck at the skyscrapers, cars and throngs of smartly dressed people and silently rejoices. Somehow, somehow, that terrible war was won.

Forty years after they raised the white flag, the Japanese have handed history one of its choicer ironies. They have achieved in defeat much of what they sought fruitlessly in war: affluence, military security, the respect of foreign countries and economic domination of East Asia.

But with all its success, Japan continues to see itself as a society living on the edge. It is forever debating what it owes to the world, how long the good times can last and whether wealth has brought true happiness. To that last question, more and more Japanese answer no.

Not that anyone would turn back the clock. Japanese today live longer than any people on earth. Life expectancy is now 80.2 years for women, 74.5 for men. They enjoy excellent health. They can pass from cradle to grave without a single encounter with violent crime. Their streets are clean, their waiters polite and their televisions tuned.

It has reached the point that on Sunday afternoons, hundreds of young people have nothing better to do than dress up like American teen-agers circa 1958 and dance for hours to golden oldies, boosted to megadecibel levels by the latest Sony tape players, in and around Tokyo's Yoyogi Park.

When Japan surrendered on Aug. 15, 1945, Tokyo and the other great cities were blackened fields of ash and twisted metal. Most factories were ruined and ships sunk. Three million Japanese were dead. Many of those who had survived were living on diets of sweet potatoes and other roots.

The devastation was so complete that American paratroops scouring Yokohama city for food for occupation chief Gen. Douglas MacArthur's first breakfast in Japan reported back with one egg.

The reconstruction began.

"People came to believe that happiness is found in having things and money," said Jiro Kamishima, a political science professor at Tokyo's Risho University. They approached the new task at hand with the single-mindedness they had applied to making war.

Americans say the squeaky wheel gets the grease. But Japanese say the nail that sticks up gets hammered down. And by most accounts, conformity and unswerving loyalty to the group are the keys to understanding the Japanese character and the country's stunning success on the world's commercial playing field.

Today's Japan, with its 120 million people, is a finely tuned, $1.2 trillion economy, surpassed in size only by those of the United States and Soviet Union. Its steel, auto and electronics industries are the envy of the world. A major challenge is figuring out how to sell less to trading partners fuming over trade surpluses. A Few Sagging Indicators

Popular beliefs aside, gross inefficiency does exist in Japan. Many farms, for instance, are so backward that without import barriers they would be driven out of business quickly. But in the larger scheme of things, efficient operations cover for those that are not.

It is estimated that gross national product will rise 4 percent in real terms this year. Exports, to hit $180 billion, will include power generating equipment for China, automobiles and digital phone exchanges for the United States and cassette recorders for Bahrain. The cheap toys and saucepans that once made the stamp "Made in Japan" synonymous with junk vanished years ago.

Since the war, the United States has become Japan's most important economic partner, taking 35 percent of its exports last year. Despite Washington's huge deficits with Japan ($37 billion in 1984) and complaints of market barriers, the United States does make major sales here. Japan is the largest foreign market for American farmers today, with almost $8 billion of purchases in 1984.

Much of Japan's trade and investment is directed at former members of the "Greater East Asia Co-Prosperity Sphere," as its wartime empire was called. At the height of its success in the war, the empire of the Rising Sun stretched from the Aleutian Islands off Alaska, through the Philippines and south to New Guinea, and from Burma to northern China, to Singapore, Hong Kong, Indochina and Malaya (now part of Malaysia). Japanese blanch at historical parallels but in the same breath suggest that economic dominance of the region is a natural byproduct of industrial might.

The Indonesian oil reserves that Japanese troops seized in 1942 to fuel the warships of the Imperial Fleet are again producing for Japan, this time on long-term contracts at OPEC-influenced prices. Japanese goods and factories are found all around Southeast Asia, Taiwan and South Korea. They show up in China, too.

There are no Japanese soldiers today on Saipan, the Micronesian island that U.S. Marines secured in 1944 after one of the fiercest battles of the Pacific war. But it is dotted with Japanese restaurants and hotels for the thousands of Japanese vacationers every summer.

Despite these facts, the Japanese are quick to contend they have a long way to go. Japan has been called a rich country inhabited by poor people. Gross national product, while huge in absolute terms, ranks only 14th in the world on a per capita basis. In many measures of the quality of life, Japan ranks even lower.

The typical home is tiny, cold in winter, hot in summer and overpriced. By American standards, bedrooms are often walk-in closets. A European Community official's remark some years ago about "rabbit hutches" will forever be remembered here. In 1983, only 58 percent of all homes in Japan had flush toilets.

Japanese cities have practically no park space (on a per capita basis, Washington has 23 times as much as Tokyo) or sidewalks. Sanitation is so backward that some Tokyo streets smell of raw sewage. Refineries and factories mar a formerly beautiful coastline.

Today, Japanese are increasingly asking questions about the social cost of the great economic miracle. What happens to family ties when fathers routinely come home at 11 p.m.? How sane and stable can children be when life for them is an unrelenting battle -- military terms are common in day-to-day conversation here -- for entrance to a good school?

Modernization has already ravaged many of the old village relationships. Divorce, while rare by western standards, is on the rise. Hardly any young Japanese today say the support of old people is the family's responsibility. As a result, more than 900,000 Japanese women over age 60 are living alone.

Among the countless English words the Japanese have adopted is sutoresu -- stress. There are many ways of coping with sutoresu -- golf, pinball parlors and drinking. The Ministry of Health and Welfare estimated recently that 2.2 million Japanese would benefit from professional treatment for alcoholism.

Prime Minister Yasuhiro Nakasone raised eyebrows earlier this year by suggesting that people take all their allotted vacation time. Leisure is seen increasingly as the key to solving both Japan's spiritual woes and its tensions with foreign governments, which feel that more play will mean fewer exports and more imports.

It fits into a larger debate in progress within the ruling Liberal Democratic Party. Almost everyone there agrees, in public at least, that Japan has sunk too much money into efforts to increase the gross national product. The big question is how much more it should put into housing, sewage systems, campgrounds and other "social infrastructure."

That goes to the heart of Japanese frugality, and it is an issue that will not be settled easily. The typical Japanese household today is still saving around 17 percent of its income, compared to 5 percent in the United States. Those savings traditionally have been invested in more production, not leisure.

Looking to the future, Japan is in fine shape from an accountant's point of view. In the early 1990s, it will be sitting on a mountain of accumulated trade surplus dollars, $400 billion by some estimates. Japan's already emerging role as banker to the world will be confirmed.

Most economists here predict that Japan's large factories will continue to modernize rapidly, putting robots and computers on the assembly line. Industry will pack more and more "added value" into the raw materials it imports from abroad and resells as finished products.

At the same time, fewer Japanese will work hands-on jobs on assembly lines, predicted Josen Takahasi of the Mitsubishi Research Institute. The fast-growing fields will be the "soft" sides of the factory process, such as design, and computer control of production. These will allow factories to shift away from standardized products toward ones that are customized right on the assembly line to each customer's tastes.

Japan will have to keep one step ahead of fast-developing countries like South Korea, Taiwan and Singapore, which already are close on its heels. So far, Japan is managing. For instance, this year, as South Korea exported its first video cassette recorders, Japan brought to the market the world's first 8-mm systems, the next generation in home video.

Japan's emergence as one of the world's oldest populations will pose another economic challenge. At present, there are approximately six working-age people to support every Japanese over 65; by the year 2000, there will be four. Ten years after that, there will be only three. Productivity will have to rise rapidly just to keep things even. The Work Ethic Lives

Many older Japanese, meanwhile, are afraid that the new generation lacks the mettle for the task ahead. The newspapers are full of shocking (by Japanese standards) evidence: school bullying, motorbike joy-riding and girls who don't know how to tie the belt of a kimono.

"Japanese children have a low sense of public spiritedness and seldom help with household chores," laments a report by the Economic Planning Agency.

But experts who give the question serious study often conclude that, despite young people's demands for more time off, the old ethic of hard work and loyalty is essentially intact. The dancers at Yoyogi Park obey instructions from the local police. Teen-agers may dye their hair blue but they still bow to their parents.

"When they are recruited by companies, they become very faithful, loyal members and work as hard as the older generation," remarked Bunroku Yoshino, chairman of the Institute for International Economic Studies.

Still, many Japanese, like Mayumi Sano, 17, a Tokyo high school student, remain apprehensive.

"I am happy now," she said, "but I am convinced the day will come when Japan will again face poverty and misery. I can't say why, but this prosperity and happy times cannot last forever."

Earthquakes, typhoons and volcanos have for centuries fostered a belief that human endeavors are built on sand. Today's prosperity, however, has an added vulnerability: virtually all the oil and resources that keep Japan lit and humming come from somewhere else.

Every time a rocket hits a tanker carrying oil in the Persian Gulf, Japan is reminded how easily the flow could be shut off. Every time the yen slips or gains a point on the world's foreign exchange markets, corporations and banks around the country feel the effects.

Despite this dependence, Japan, more than any other industrialized nation, feels ill at ease with things foreign. Japanese shoppers spurn imported goods. Young people who have been educated overseas have trouble finding good jobs because companies fear they might have the wrong attitudes. Some end up going to special schools for deprogramming.

The Japanese government contributed $40 million last year toward supporting Indochinese refugees in camps in Southeast Asia. But in 10 years it has accepted only 4,300 of them for permanent resettlement here. General crowding is cited, but the government also seems to fear that the cultural homogeneity would be threatened.

At the same time, Japan remains a faceless nation to the rest of the world. Movies, magazines and U.S. government cultural centers give foreigners a feel for Americans and their way of life. Japan, on the other hand, is known mainly by labels on its products.

Thousands of English books are translated into Japanese annually. But only a handful of Japanese books are published abroad. Yukio Mishima excepted, most educated Americans cannot name a single Japanese author. Japanese diplomats sometimes comment that what Japan needs is a personal ambassador -- a star on the international tennis circuit, for instance.

Internationalize, the Japanese are told relentlessly. NHK, the quasi-government television network, tries to help by broadcasting foreign-language lessons. Some companies are hiring their first non-Japanese employes. Nakasone has tried to set a personal example, stopping at a Tokyo department store recently with press cameras clicking to buy an Italian necktie, French sports shirt and British dart game.

The government, arguing that Japan's industrial status has given it new responsibilities abroad, is slowly expanding the country's role in the world beyond that of an exporter. Defense and foreign aid are the only two categories of the national budget that are consistently growing these days; both are outward-oriented.

Japan now devotes about $4.3 billion a year to foreign assistance. Under constant pressure from the United States to contribute more to regional defense, it is conducting a military buildup that has extended deep into the Pacific.

Still, memories of the war and a belief that caution has served it well in the past 40 years continue to restrain Japan from exercising any meaningful leadership in the world's noneconomic forums. It continues to be a follower of the United States.

Japan prospered like no other country under the world order that the United States created after 1945. Despite simmering trade disputes, it continues to view the United States as the best friend it has. But as Americans fight inconclusively with productivity and deficit problems, Japanese fear their friends and protectors have lost their way.

"We're traveling the same road," said Yoshino of the Institute for International Economic Studies, dismissing suggestions that Japan is prepared to strike out on its own. "What we miss is a United States that has a comprehensive philosophy and gives us guidance."