Java will work the same on any OS. To give you some insight.
Java makes use of bytecode. When the source code is executed, the .class file is generated compsisting the bytecodes. Bytecodes are then interpreted by JVM which is the machine where your program will be run. (also known as JRE)