Japan modernised as a result of internal and external pressures.Externally, Japan was pressured by the Dutch, and specifically Commodore Perry to open it's doors to trade. If they refused, Commodore...
It took the majority of Europe around 150 years to modernise, but it took Japan only 40 years (at an average) to catch up after having missed the industrial revolution while being in the Edo period...