Writing a Java application consists of several steps: writing the code, compiling the code, and executing the application. Java source code is stored in a text file with the extension .java. Compiling the code creates one or more .class files, which contain processor-independent byte codes.
The Java Virtual Machine (JVM) then translates the byte codes into machine-level instructions for the processor on which the Java application is running.
Thus, if a Java application is running on an Intel Core i9-9900K processor, the JVM translates the byte codes into the i9-9900K’s instruction set.
You can get a Java SE Development Toolkit (JDK) on the Oracle website free of charge. The JDK allows you to build applications, applets, and components using the Java programming language. In addition, the JDK contains a broad range of prewritten Java classes that programmers can use in their Java applications. If you are downloading and installing Java yourself, be sure to choose your appropriate operating system when you download, and follow the directions on the Oracle website, including the directions for setting the path for javac, the Java compiler. You need to set the path correctly so that you can run the Java compiler from any directory on your computer. To develop an application using the JDK, write the source code using any text editor, such as Notepad on Windows, TextEdit on Macs, or the vi editor on a Unix operating system. To compile the code, invoke the compiler from the command line:
where ClassName.java is the name of the source file. So remember that when you save the source code you write into the text editor, this must end in .java.
If your program, written in the file ClassName.java, compiles correctly, a new file, ClassName.class, will be created in your current directory. To run the application, you invoke the JVM from the command line:
Okay, now never do that again.
Typically, programmers use an Integrated Development Environment (IDE) instead of a text editor and the command line to develop applications. An IDE consists of a program editor, a compiler, and a run-time environment, integrated via a Graphical User Interface. One of the many advantages to using an IDE is that errors in the Java code that are found by the compiler or the JVM can be linked directly to the program editor at the line in the source file that caused the error. Everything looks nicer too – the Graphical User Interface enables you to have the editor and compiler in the same place, and therefore execute the program without launching separate applications:
Pick one at random.