Skip to content

JDK Installation and Setting its Path and Running Java Program

This is detail tutorial on installation of jdk and setting its path and running your first java program.

Read article carefully to understand how to set path temporary and permanent way. Follow the green squares.

First we need to install JDK(Java Development Kit) Click here for download link
Choose Java Platform (JDK) 7u45

Accept Licence Agreement and see download link at bottom select file as per your os. If you have 32 bit windows select windows x86 and x64 for 64 bit

Download the file & installation is very easy just follow the instruction

Once you installed Java on your machine, you would need to set environment variables to point to correct installation directories:
First we need to copy the path of jdk, bin folder path
Go to C drive > Program Files > Java > jdk Folderbin folder and copy the path

There are two ways doing it..

1. Temporary set path
Open command prompt
Click on start and search box type cmd and enter

Once it open give your copied path like this “path=C:Program FilesJavajdk1.7.0_45bin”

To check whether the path is set or not type javac and enter and you will see java options that means your path is set and ready to run java programs

2. Permanent way to set path
Hope you have copied the jdk folder path which is explained above
Click on Start > Right Click on Computer and click Properties

Then go to Advance system setting or you can simply type in start search box for advance system setting

System properties dialog box will open click on Environment Variables

Click on new in System Variable. Note:Don’t add path in user variable it will not work
Add Variable name as path. Note: anything else than path will not work like java or sdk
And Variable value as path you copied with Semicolon at end. Note: don’t forget to add semicolon(;) at end.

To check whether the path is set or not
Open command prompt and type javac and enter and you will see java options that means your path is set and you are ready to run java programs

Running Java Program
Open your favorite text editor
And type this program or simply copy it

class testing
 {
public static void main(String args[])
{
System.out.println(“Hey! This is my First Java Program..”);
}
}

Then save it as .java extension. I saved it to my F drive in sush folder
Note: save your program with your class name Otherwise it won’t run.
Now how to compile it
open Command Prompt Then we need to change present working directory in cmd. (I saved my program in F drive sush folder)
For that type your drive name like F: > cd sush (cd is change directory)

To compile java program type javac filename.java and enter.
If everything went correctly it will come to next line without any error and it will also create class file of your program in same folder

Now to run the code type java filename

Howdy, we have done it. 🙂

Comment bellow for your Query and Feedback

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!