javatutelearn.com

Easy Learning


Home

Search Javatutelearn.com :



Java Introduction

  • Java is platform independent programming language.
  • Java creates a bytecode that can be run on any type of machine with the help of Java Virtual Machine (JVM).
  • Java is secure language because java is not using pointers.
  • Java is also called "write once and run anywhere" programming language.

First Java Program

  • Java program can be written in Notepad or any text editor.
  • Java program starts by creating a class.

Example

class FirstJavaProg {
	public static void main (String args[])
	{
		System.out.println ("Hello ! Dear learner");
	}
}

Output of the program

Hello ! Dear learner

Explanation of the program

  • A class named FirstJavaProg is created.
  • A java program starts from main() method. Hence, main() method is created in the class.
  • Main() method must be defined as public static void and must receives array of arguments of String type .
  • To display a message, the statement System.out.println() is used.
  • Class and main() method are properly closed by curly brackets.

Compiling Java Program

  • Java program is complied using the command.
    		javac FirstJavaProg.java
    
  • If command 'javac' is not working, then set 'path' environment variable to java directory.

    Example

    		set path = C:\Program Files\Java\jdk1.8.0_102\bin
    

Running Java Program

© Copyright 2016-2024 by javatutelearn.com. All Rights Reserved.