Thursday, December 25, 2014

Java program to show "Hello World!"

Java is a platform independent programming language. That's why we can run a java program in every operating system like Windows OS, Linux OS, Mac OS X etc. But we have to install JDK (Java Development Kit) in our computer system to run java program. After installing the essential JDK, you have to use a text editor also to type the program. I personally use TextPad text editor to type the programs and to compile & run them easily. Follow the steps given below, all the necessary software and instructions are given to run your first java program.

The program given below is a Java Program to show Hello World!. To run this program, you have to follow the steps given below.
public class HelloWorld{
public static void main(String [] args){
System.out.println("Hello World!");
}
}

 Step 01  Download JDK and install it
To run a Java program, first of all you need to install JDK (Java Development Kit) in your computer system. So, download JDK and install it properly. The installation process is very simple.


Watch the video to learn how to make ready your PC
for running Java Programs
 Step 02  Download TextPad and install it
After installing JDK, you have to install TextPad text editor. So, download TextPad and install it now.

 Step 03  Restart the computer and write your program
Now restart the computer and open the text editor TextPad. Type the above Java program in it and save the program as the class name using .java extension. The class name you will found at the last of the first line of the java program. For example: public class HelloWorld is the first line of the above java program, and HelloWorld is the class name here. So, you need to save the program as HelloWorld.java

 Step 04  Compile the java program and run it
After saving the program, now press ctrl+1 to compile it and then press ctrl+2 to run the java program.

Things you should remember...
1. Class name may be anything depending on your choice, but the program should be saved with the same name and must with .java extension.
2. Java is case sensitive, that's why the object names should be same as defined. For example: System.out.println, the first letter of System must be in capital letter.


2 comments: