First Basic Java Program

First Basic Java Program

Previous Home Next


In this we are going to create a very simple first program of Java which display "Hello to R4R"

To make and run a Java program we need only notepad and jdk(Java development kits).You have to follow following steps: 

* download jdk latest version from sun websites.
*Install jdk
* set path Path can be set by two type

1.In set path for workspace(In which directory you are working)
2.Set environment variable so that the path will set for all directories .

Now you can save and run your program any place on your system.

* Write following code on notepad and save it with name of R4RFirstJava.Java. Here be insure file must be in .java extension some time it save with extension by default .

So Now you have save it within “” eg “”.

 * Start cmd Say I have save my file into C:/r4r Then to compile with command prompt C:/r4r> javac

*To run C:/r4r> java R4RFirstJava Hello R4R The output: Hello R4R will display on command prompt.

Here in this program we have make a class with name of R4RFirstJava. 

Before proceed forward just focus on syntax of class writing used into
java Syntax:

Access_specifier class Class_Name{ //Body Of Class }

* The Access_specifier may be public private, protected or defaults .It depended on type of class .

There are mainly four type of class which we will discuss later in this tutorials.

* class:class is Keywords which is used to create a class.

*Class_Name is your class name which may any Name except keywords and reserved words.


//first java program display "Hello to R4R"

public static void main(String[] args) {
System.out.println("Hello to R4R");

Hello to R4R
Previous Home Next