Java is a platform independent language. You just have to compile all those .java file once and then any OS that has proper JVM support will execute it w/o compiling it back, unlike other programming languages, for that specific OS. You do not have to rewrite your code for the specific operating system.
That's why they say, run/compile once and execute it anywhere.