Java code is not compiled into .exe (Windows) or .app (Mac). Instead, it is compiled into .class files containing Bytecode—an intermediate, highly optimized set of instructions that the JVM understands. This allows the same binary file to run on any hardware that has a JVM installed, from servers to mobile devices.
A .jar file compiled on your Windows laptop will run identically on a Linux server in the cloud, as long as both have compatible JVMs installed.
A developer sends you a .class file compiled on Windows. Can you run it on your MacBook without recompiling?