Getting Started with Java

Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn3Share on Reddit0Pin on Pinterest5Share on StumbleUpon2

Before the learning JAVA we have to download the latest version of Java from here .

Java Installation in windows 
Once java is downloaded in your system, it can be installed like any other software (.exe) in your Windows system.

Setting up the Environment Variables
After installing Java there are some steps that need to be follow as below

CLASSPATH : This environment variable points the location of JDK home directory. It also contains the address of the folder from where the jars get loaded by the ClassLoader (For more details of ClassLoader visit here)
JAVA_HOME : This environment variable will point the location of Java home directory.

Check that Java is Installed or Not
To check the java is installed properly in your system, open Command Prompt . To open command prompt write CMD in run and hit enter. Now in the command prompt window write “java -version“ as written below. 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

C:UsersJbt>java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)

If there is any problem while installing or in setting up the enviornment variables output on the command prompt will be like

'java' is not recognized as an internal or external command,
operable program or batch file

Lets Start the 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 ThatsJavaInfo ! “. 🙂

If everything till now was configured properly then we can start writing our first application. Open the notepad and write the below code.

Once done save the file with the name “FirstProgramme.java“. Please note that the name of the file should be the same as the name given to the public class. 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.

C:UsersJB>cd C:JB

C:JB>javac FirstProgramme.java

C:JB>

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.

Run Java Application
Now that your java file is compiled we can execute the application with the help of “java” command as below .

C:JB>java FirstProgramme
Hello ThatsJavaInfo!

C:JB>

Note*: For the “java” command we use only the class file name without its extension(.class).

Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn3Share on Reddit0Pin on Pinterest5Share on StumbleUpon2

About Team

Browse Archived Articles by Team

  • Avinash

    A very good post to start learning Java