JAKARTA -- Indonesia, with one of the most ardently anticommunist governments in Southeast Asia, is slowly building solid political and economic ties with its powerful communist neighbor, Vietnam.

The odd-couple relationship has perplexed Indonesia's neighbors, while underscoring the schisms among Southeast Asia's noncommunist states over which country represents the region's biggest security threat.

The budding ties between Jakarta and Hanoi were fortified late last month when Vietnamese Deputy Prime Minister Vo Van Kiet led a 12-member economic delegation to Indonesia to discuss possible investment opportunities in Vietnam after the expected passage later this year of a liberalized foreign investment code.

The two sides also discussed various technical exchanges and announced a future visit by a team from the Indonesian state-run food agency to help Hanoi with its food distribution and storage problems.

Indonesian political analysts also have speculated that Kiet was interested in tapping into Indonesian oil technology, in exchange for offering Jakarta the best sites for off-shore exploration in Vietnam. "We have always been open to Vietnamese technicians who want to learn about oil technology," said Mochtar Kusumaatmadja, Indonesia's foreign minister, after Kiet's visit.

Expanding relations with Vietnam has both economic and political benefits for Indonesia, with the world's fifth-largest population, according to government officials and foreign and domestic analysts.

Economically, Jakarta is "looking to the post-Cambodia era," in the words of one respected Indonesian journalist, meaning that Vietnam eventually will end its nine-year occupation of Cambodia, removing the major political obstacles to improved ties with the rest of the region.

Whenever the Cambodia issue is settled, economic analysts predict a scramble by countries wanting access to Vietnam's markets. By building links now, Indonesia will gain favored status.

Politically, the Indonesian government believes that a stronger Vietnam provides an important regional counterweight to China, which Jakarta still views as its major threat.

Older Indonesian officials, particularly from the powerful military, remember China's support for the old Indonesian Communist Party (PKI), which launched a bloody coup attempt in 1965 by murdering several prominent generals. Indonesia broke diplomatic relations with China over Beijing's involvement in the incident, and formal ties still have not been restored more than 20 years later.

Asked whether fear of China was a factor in building ties with Hanoi, Mochtar, in an interview, replied, "Frankly, yes. We believe in a strong Southeast Asia, including a strong Vietnam."

"We will be happier to have the Vietnamese next to us than the Chinese," said Harry Chan, vice chairman of the Center for Strategic and International Studies, an influential think tank that often echoes government thinking. "We believe Vietnam is more nationalist, rather than just communist. . . . We believe they are first Vietnamese and second communist."

Ironically, Indonesia's growing ties with Vietnam would seem to hamper progress toward the country's other long-range foreign policy goal: to strengthen political cooperation and regional self-reliance among the six noncommunist nations of the Association of South East Asian Nations (ASEAN) that includes Thailand, the Philippines, Malaysia, Singapore and Brunei.

Many Indonesian political analysts and academics have been discussing prospects for a new Southeast Asian security arrangement, given the possibility that the United States might have to withdraw from its two military bases in the Philippines in the next decade or two. Indonesia, with 165 million people the largest country of the six ASEAN nations, naturally would take a leading role in any future security arrangement.

The problem is that no two countries in ASEAN appear able to agree on the common threat.

Thailand, a front-line state in the Cambodian conflict, is most concerned about perceived Vietnamese expansionism, and Bangkok has been building solid ties with China in recent years, even purchasing new Chinese arms.

The Philippines, when not distracted by internal problems, seems most concerned about the Soviet Union maintaining bases at Cam Ranh Bay in Vietnam, across the South China Sea. Singapore and Malaysia are more concerned about each other because of lingering Malay-Chinese animosity.

"What ASEAN does not have -- and what the European Community does have -- is a NATO," said Juwono Sudarsono, a political scientist at the University of Indonesia. "The European Community has a clear sense of imminent danger. There is no basic common denominator" of a Southeast Asian threat.

Indonesia also has an emotional basis for close ties to Vietnam, born of the two countries' shared experiences. Both fought long wars for independence, Indonesia against the Dutch and Vietnam against the French. And the two countries declared independence from their colonizers within a month of each other -- in August and September 1945.