First Java Program

Advertisements

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 "First.java" file name. We can save our java program anywhere in our system or computer.

Create First program

Example

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 First.java
To execute:  java First

Output

Hello Java
My First Java Program

Save Java Program

Syntax:
        Filename.java
Example:
	First.java

Compile Java Program

Syntax:
	Javac  Filename.java
Example:
	Javac First.java

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

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements