JAVA_HOME : This environment variable will point the location of Java home directory.
How to set environment variable in different platforms
Windows XP
To
set up environment variables in Windows XP right click on the “My
Computer” icon and select Properties. In the Property window select the
“ADVANCED” tab and click on “ENVIRONMENT VARIABLES” . A window will
appear were you can enter a new environment variable under System
Variables by clicking on the New button.
Windows Vista / 7
To
set up environment variables in Windows Vista / 7 right click on the
“Computer” and select Properties. In the Property window select the
“ADVANCED SYSTEM SETTINGS” and then select the “ADVANCED” tab and click
“ENVIRONMENT VARIABLES”. A window will appear were you can enter a new
environment variable under User/System Variables by clicking on the New
button.
How to Check if Java is Installed
To
check if your java is installed properly open Command Prompt . To open
command prompt write “CMD” in run command and hit enter. In the command
prompt window write “java -version“. If your
java is installed properly and all environment variables are configured
correctly it will show the version of Java installed . Information
reflected on the command prompt will be like
How to check if Java is up to date
To know if the Java installed on your system is up to date or not
Click Here.
Our First Java Program
It is highly common that the very
first Java program would be to print ” Hello World !! ” . But here we
will write a program to print ” Hello JBT !! “.

If
everything till now was configured properly then we can start writing
our first application. Open any editor and write the below code.
Once done save the file with the name “
HelloWorld.java“.
Please note that the name of the file should be the same as the name
given to the public class(For more details regarding class file rules
click here). Once the file is saved, open the command prompt and change its current directory to where the file is saved with the help of
cd command. And fire “javac” command which is used to compile the java code as below.
If the java file is compiled properly the compiler will create a class
file for the java source file. It will be saved in the same location as
the source file or maybe some other location depending on its package
declaration. Since there is no package declared in the given code so the
.class file will be created in the same folder location.
How to Run Java Application
Now that your java file is compiled we can execute the application with the help of “java” command as below .
Note*: For the “java” command we use only the class file name without its extension(.class).
With this we are done with creating and running our very first Java application.