I wouldn't exactly call the Japanese the "underdog" by any means.
Granted, they were one very short step out of the Middle Ages when Perry forced his way into Yedo, but that didn't last very long. The Japanese looked around, saw what worked and why..... and copied it.
Their Army was modelled on German originals, as much of their equipment. Improvements and modifications were made to suit local manufacturing conditions, to satisfy national pride ("THIS rifle is OURS!!") and to avoid the necessity of paying much in the way of royalties for the designs they were stealing. Their navy was modelled on the Royal Navy, at that time the biggest and best in the world.
By 1904 the Japanese Army and Navy were good enough to take on.... and defeat decisively..... the forces of the Russian Empire. Japan ended up with Sakhalin and Port Arthur and Russia didn't get them back until the end of the Second War.
China, then as now the most populous country in the world, had been buying Western technology and Western weaponry since the 1870s. Japan ripped into China in the 1930s and the results were anything except pretty. They took on the British Far Eastern Fleet next, then attacked the US. That takes more than just guts: it also takes CONFIDENCE that you can DO THE JOB.
No, Japan was anything EXCEPT the underdog. It was heavily-armed, heavily-militarised, expansionist and aggressive..... and merciless toward its victims.
It was NECESSARY to destroy that..... and it was a hard job.
Just trying to put things into a bit of perspective.
.