Lets see how java works:
You can use notepad or any IDE (like Eclipse) to write a java program. If you are using notepad, make sure to change the extension of the file from .txt to .java.
Java program, which is just a set of instructions in java language, is first compiled (say translated) by Java Compiler into intermediate language in a file with .class extension. These intermediate files are also called Bytecode.
After this, JVM (Java Virtual Machine) interprets the Bytecode (a java binary file) for a Computer's Processor (any hardware platform). JVM produces the same result irrespective of the platform used, thus eliminating the need for programmers to rewrite or re-compile the code for different platforms.