First JAVA program


First Program:

class Demo{
                public static void main(String[] args){
                                System.out.println("Hello World");
}



Output :

Hello World!

Steps to write a java program:


  • First you have to install jdk in your system.
  • Then set the javac path : 
  1. Copy the path where you installed the jdk.
  2. e.g. C:\Program Files\Java\jdk1.8.0_121\bin
  3. Now go to properties of my computer. In advanced menu click on environmental variable and set path.
  • Now write a java program and save it with program name with .java extension.
  • For compile the program we write: javac program_name;
  • If program is successfully compiled then we can execute the program using following command: java program_name;




Note: If a java program contains more than one classes then we can save program with any name and program is compiled. Program is run only by the name of the class which is containing main() method.


Comments

Popular posts from this blog

Decision Making Statements

Data Types

What is JAVA?