Compiling an Application

JDK can compile both Java Applications and Applets. This document describes how to compile and execute a Java Application. A Java Application executes outside of a Web Browser. Java applications can output directly to the DOS window. Applications can also create their own Windows and support a very complex User Interface.


This first step is to create a directory that will hold your Java project. Your Java project may have several files associated with it, so using a separate directory can help you keep organized. Start by opening a DOS window. Do this by selecting "command prompt" from the start menu.
Use the command MD to create a directory to hold your project. Then use the command CD to change to that directory. You only need to use the command MD once to create your directory once.

Now you need to create a short Java source file to compile and execute. Type the command notepad HelloWorld.java and you will see note pad pop up and ask if you would like to create the file. Say YES.

Now key in a short simple Java Application.

To compile the application enter the command javac HelloWorld.java. This will produce the output file HelloWorld.class. Do not use the command javac HelloWorld. This will not work. Once compiled the program can be executed by entering the command java HelloWorld. Note that when executing you DO NOT specify the .class extension.