SiteMap  | About    

First java Program

The most common example of a first Java program is the famous Hello World! program. Before going to your first Java program you should download and install JDK (Java Development Kit) properly. The following link will guide you to download and install JDK on your system.

Click here Downloading and installing JDK software

Writing a Java hello world program

You should follow three steps to completely run your first Java program.

  1. Create a source file
  2. Compile the source file
  3. Run the program

Create a source file with .java extension

In your text editor (ex: Notepad in Windows) , create a new file and save it as "". HelloWorld is your class name and you will need your class name to be the same name as your file. Copy the following source into your file.

Compile the source file into a .class file

A compiler is an application that translates programs from the Java language to a language more suitable for executing on the computer. In order to compile your java file, navigate to the folder where you saved and type in javac

If there are no errors in your code, next step is to run the program.

Run the program

After successfully compile the, you will get a HelloWorld.class file in the same directory. In order to run your program, in the same directory, enter the following command at the prompt:

Just after you press enter key, you will get the message "Hello, World" in the next line. Congratulations! Your first Java program completed successfully! (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.