Developing a Java Application

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.

Screen Shot 2018-12-07 at 5.29.57 PMThe 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:

Screen Shot 2018-12-07 at 5.13.43 PM

where 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, 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:

Screen Shot 2018-12-07 at 5.40.21 PM

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:

Screen Shot 2018-12-07 at 5.56.33 PM


Some of the many available IDEs include Eclipse ; intelliJ IDEA; BlueJ. Use Google for more.

Pick one at random.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s