Both Japan and China were extremely wary of Europeans at the time of their early contacts. There were at least two reasons for this.
First, both countries felt a certain degree of superiority over the Europeans. Both countries felt that they were culturally superior and therefore did not need or want anything that the "barbarians" had to offer. Second, both countries feared the influence of the Europeans in the political struggles of the time. They worried about the influence that Catholic missionaries, in particular, might have. For this reason, both countries tried to prevent the Europeans from having much contact with their people. They did things like confining European contact to small areas in remote areas of the countries. Japan later took this even farther by closing itself off completely in the Tokugawa period.
Both China and Japan had faced similar challenges from the West (both faced severe challenges from Western imperial powers and ended up signing unequal treaties with the West, with the new foreign presence instilling new waves of domestic turbulence) but had responded in very different ways. The elites of both countries responded to the challenges posed by Western penetration by initiating reforms. In Japan, the Meiji regime chose to remake themselves entirely through Westernisation, while in China, the Qing government chose instead to hold on to traditional Chinese values and institutions. China’s efforts at reforms, including the Self-Strengthening Movements and the Tongzhi Restoration, were in essential traditional answers to traditional problems. There was no significant, large-scale industrialisation in China and the Machus displayed little willingness to abandon traditional imperial institutions that were incapable to dealing with contemporary problems. Chinese cultural pride was just too deeply ingrained, so much so that it became an impediment, blinding many Chinese and preventing them from recognising the need to learn from the barbarians and for fundamental change. On the other hand, Japanese efforts to adopt foreign technology to meet their military and industrial needs were largely successful. The Meiji regime, however, saw that military technology and industrialisation could not be separated from institutional structures that had produced and accompanied such developments in the West, and showed little hesitation in transforming or abolishing traditional institutions in favour of those that could give Japan the modernity it needed to survive. Overall, the Meiji Restoration was a tremendous success for the Japanese and allowed them to join the ranks of Western new imperial powers.