Monday, 3 August 2015

How to run a Java Program



Java the one and only programming language which is used in more than 300 billion devices.

James Goslin, Mike Sheridin, and Patrick Naughton initiated the Java Language Project in June 1991. Initially Java is named as OAK (Oak tree was outside the Goslin’s office) later it was named as Green then finally named as Java from Java coffee.Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar.


At first Java was released in the year 1995 by the Sun Microsystems later in 2009-2010 Java was owned by the ORACLE corporation.

Java is platform independent it assured that Write Once Run Anywhere(WORA).

Let us start coding…..

In order to run the Java program we need an Java Developement Kit (JDK) .

Download the latest jdk

Open the browser and Download the JDK




Then install the JDK


To check that the Java is installed on your computer open the command prompt and type JAVA and click Enter.


Ok you are done…

Open the Note Pad and type the following Java code


import java.lang.*;

public class demo


public static void main(String args[])


System.out.println(“This is my first java program”);




Then save it in a well-known destination path

The saving should be as in the above program the class name is demo.

So save the file as

You should remember the path of saving because it is required for the next process.

To run the Program open the command prompt



in that type the local disk drive letter that you have saved.

I have saved it in the E disk.

type E: the cmd


Then change the directory(folders) to which you have saved the Java file using CD folder name command



i have saved the java file in the above path as

we need to compile the program.

type the following command in cmd


here it is javac and click Enter


If there is no error the next line for command will be displayed else the errors will be displayed


Then we are now ready to run the program type the following command in cmd

java filename

here it is java demo and click enter the output will be displayed.


hurray we got the output…

Congratulations You became the basic Java Developer…

Basically while compiling for the first time error will be occured. I will help you to recover the error in the next tutorial…

Stay tuned…….

No comments :

Post a Comment