In Japan, although various daimyo (regional lords) accepted some of the new technologies and certainly the trade from Dutch, English, and Portuguese traders, the Catholic missions to Japan quickly converted hundreds of thousands of Japanese to Christianity. Some of the Christian converts were rebels against Tokugawa Ieyasu, the new shogun who had finally united Japan after 100 years of civil war. An English trader who had become an advisor to the shogun warned that the Catholic missionaries would seek to instate papal rule across all Japan, which indeed they tried to do by stating that the highest authority in Japan was not the shogun or the emperor, but God and God's representative on earth, the pope. Ieyasu and his successors martyred over three hundred thousand Christian converts, then limited trade relations with gaijin (foreigners) to a single port city in the south-east. The guns and cannons which European traders had introduced had played a huge role in deciding the civil war's outcome for Ieyasu, and being able to control those weapons certainly played a part in the shogun's decision to close off trade with the rest of the outside world. For more information, you may want to read Samurai William by Giles Milton, which gives a very in-depth account of European trade in south-east Asia and Japan in the 16th and 17th century.
For China, Europeans were allowed to conduct trade in enclaves, or walled-off portions of trade cities. The imperial ministers had much the same reasons as their counterparts in Japan for restricting foreign trade: religion and technology would disrupt the society and ultimately the government. The Chinese were not entirely isolationist in their trade policy, though; European trade brought new goods and inflows of silver to China, which enriched Chinese culture and society without disturbing it, since cultural (imperial) censorship often dictated which goods could or could not be traded into China.
Tokugawa Japan adopted the foreign policy of "sakoku" or closed country to prevent the entry of foreigners, especially the Europeans, into Japan. Such a policy was enforced as it helped to prevent the daimyos, local feudal lords, from consorting with foreigners to generate wealth for themselves through trade and to stop them from amassing any form of power that could allow them to challenge the central authority of the shogun. European influence via the means of trade was viewed to be a destructive force for Japanese society that had to be eliminated. Dutch traders were, however, still allowed to trade at the port city of Dejima in Nagasaki.
China, on the other hand, rejected European trade as they simply did not have the interest to sustain such efforts with the West. The Chinese did not need any form of goods from foreign states, which were viewed to be barbaric in nature, even when one considered the benefits taxation on the foreign merchants could bring. In fact, trade with the outside world was maintained only through tributary missions that maintained China's central position in the balance of power.The Chinese were, similarly, not entirely closed off from the West. A Canton trading system had been initiated by the Qing government to regulate foreign trade, where a Canton trading guild, called the Cohong, had been entrusted with the duty of dealing with the foreign traders.