You can stay in Japan as long as you are granted a working visa. The length of your visa depends on the type of visa you have and your situation. You can apply for a visa online, at an embassy or consulate or by visiting the Immigration Bureau in person.
If you are a non-Japanese national, you can apply for a visa online or in person. You can also apply for a visa online if you are a Japanese national, but you must apply at a Japanese embassy or consulate. If you are a Japanese national, you can apply for a visa online or in person. You can also apply for a visa online if you are a non-Japanese national, but you must apply at a Japanese embassy or consulate.