First Java Program

Prev Tutorial Next Tutorial

First Java Program

Requirements for java Program

For executing any java program we need given things.

  • Install the JDK any version if you don't have installed it.
  • Set path of the jdk/bin directory.
  • Create the java program
  • Compile and run the java program

Steps For compiling and executing the java program

Java is very simple programming language first we write a java program and save it with program class name.

In below program we create a java program with "First" name so we save this program with "" file name. We can save our java program anywhere in our system or computer.

Create First program


class First
public static void main(String[] args) 
System.out.println("Hello Java");		
System.out.println("My First Java Program");		

Compile and Execute Java Code

To compile:  javac
To execute:  java First


Hello Java
My First Java Program

Save Java Program


Compile Java Program


Note: Here Javac and Java are called tools or application programs or exe files developed by sun micro system and supply as a part of jdk 1.5/1.6/1.7 in bin folder. Javac is used for compile the java program and java is used for run the java program.

During the program execution internally following steps will be occurs.

  • Class loader subsystem loads or transfer the specified class into main memory(RAM) from secondary memory(hard disk)
  • JVM takes the loaded class
  • JVM looks for main method because each and every java program start executing from main() method.
  • Since main() method of java is static in nature, JVM call the main() method with respect to loaded class (Example: First as First.main(--))

Note: A java program can contain any number of main method but JVM start execution from that main() method which is taking array of object of String class.

Prev Tutorial Next Tutorial

Download Projects

Google Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Advertisements