When Europeans were expanding their colonies around the world, Japan made the decision to isolate itself and limit exports as a way of protecting Japanese culture from dilution or western takeover. Ultimately, Japan opened its borders when American Admiral Perry sailed into Edo Bay (modern-day Tokyo) and shocked Japan with America's superior naval technology and weapons. Perry demanded that Japan open its ports to American trade; other countries were not as lucky, and were colonized by European powers. Japan however was not colonized, but saw no choice but to open its borders to trade with other nations.
Westernization ended up benefitting Japan. While some cultural elements were made unnecessary, like the samurai warriors, other aspects of Japanese culture thrived with goods and ideas from the West.
The Meiji Restoration followed Japan's ended isolation. Under the Meiji government, the government was recentralized and the feudal period ended. Samurais became bureaucrats who studied under Western economic and political schools of thought. The Japanese military, which was no match for Admiral Perry's fleet, enforced conscription, where every male had to serve in the military for at least 5 years. This effectively abolished the samurai class, as specialized warriors were no longer necessary. Rapid industrialization was funded; Japan wanted to catch up to the West in terms of technology and industry. Also like Western Europeans, Japan engaged in imperialism, taking over Korea and later the Manchuria region of China. With better technology and nutrition from expansion, colonization, and industrialization, the Japanese population boomed. Unlike other nations, Japan managed to industrialize without a major social revolution, making westernization in Japan unique.