Core Java

Java is a simple, general-purpose and yet powerful object oriented programming language.

You can use Notpad or any other text editor(like Editplus,Notepad++ etc) to write java source code. These source files contains java programs.

Your first application, HelloWorld, will simply display the greeting "Welcome to Tech2Our!". To create this program, you copy the code into a notepad:

public class HelloWorld
{
  public static void main(String args[])
  {
    System.out.println("Welcome to Tech2Our!");
  }
}

Download code here

public class HelloWorld The class is a keyword which introduce class declaration in java.

public static void main(String args[]) The main method is the starting point of a java application. Without main method JVM will not start the execution.

System.out.println("Welcome to Tech2Our!"); This will print the Welcome to Tech2Our greeting.

Compile the Java Program

To compile the Java program, we need to use javac compiler. In this example, we have saved the program “HelloWorld.java” under in “d:\program”. So type the following command in command prompt to compile the source code.

d:\program>javac HelloWorld.java

If code has no error than compiler compile the code successfully and compiler create a byte code file “HelloWorld.class”.

Run the Java Program

To run the Java program, we need to use java interpreter. So type the following command in command prompt to run the byte code.

d:\program>java HelloWorld

If code has successfully run It prints “Welcome to Tech2Our!” greeting.