Java : Write your first java program

Posted in Environment Setup, Java By Raj On November 18, 2017


In this article, I am going to explain to you how to write simple java program, before writing your first java program you need to setup java environnment on your local machine, if you are not already set up then I would recommend you first check this article on how to set up JDK 8 and Java 

Once, the Java environment is ready then writing simple java program is very is easy and it won’t take more than 2mins here, I am going to write a simple java program which prints text on the console that is “Welcome to java world”

Step 1: Create java program 

You can either use eclipse or notepad to create a class, here, I am using notepad to create my first class, you can create a new notepad file and add below code, make sure to save it as

Step 2: Compile java class

Once the file is saved then run the below command to compile the class, after compilation in your local folder you should see JavaWorld.class file which is byte code of your class

Step 3: Execute code

Now, run the below command to execute the code

The output should be something like below

Java class

You can refer another article on how to create a class Using Eclipse