27 Dec

How to Install JDK 7 and Compile Java on Windows 7 and Windows 8

Java is powerful language on which many powerful applications are built every day. Which are used in day to day life. Learning java programming language can help you to build your own applications for your needs. But just learning java can’t help you to write your own applications for you need you need to practice coding in java every day to build a efficient and powerful java application. So in this tutorial I am going to show you On installing JAVA JDK and compiling your JAVA code.
Before continuing uninstall the previous  version of java on your computer if they are present.From Control panel->Add or Remove Programmers.(Select your java installation).
You are recommend to get 500MB free space on your installation Drive.To install JDK.

  Installing Java compiler on Windows.

Get the Latest JDK SE(Java Development Kit Standard edition)  from Oracle [official link].

Before downloading find out weather your computer is 32 bit or 64 bit computer.
You can find it from the System Properties.Under System type.
If your computer is running 64 bit operating system then you can download the 64 bit version of JDK. Else (32 bit) then you need to download the 32 bit version of JDK installer.
Here for the tutorial I am downloading JDK installer 64 bit version as my computer is running 64 bit operating system.
After completion of downloading the JDK installer run the JDK Installer on your computer.
You can change the installation location of JDK on your computer from default drive C to your convinet drive.leave to the default location if you don’t want to mess with installation.
As Windows Operating system looks for the executable files in the current directory You need to include the JDK’s Bin in the path for the execution of java files from any location on your computer.

 Steps to change the Path:

So here are some steps which can help you to edit the path environment variable
Open your control panel then Advanced system settings

advacned system properties
Switch to Advanced Tab menu then click on “Environment Variable”

 System Properties

Now search for PATH in System variables box and click on edit.

Environment Variables

When you click on edit you can find some paths already present.
You need to get the location of JDK bin folder.and add the ;  (semicolon) At last of the location

Which will be in this format c:Program FilesJavajdk1.7.0_{xx}bin;

Now carefully add the path as it is without deleting any previous paths.
And save the settings.

You can need to check if your settings are saved or not. If you can check by using path command in command prompt.

java command
Thats it! Now you have completed configuring the JDK on your computer

Now you need to verify the installation of JDk on your computer.
open your command prompt (Win+R)
and now type java -version directly on your command prompt.

java version

You will get the version details of java installed on your computer. If you did not get any message on your command promote then please check the steps once again from top.

completed installtion
To compile your java code you need to change the current directory location to the location where your code is saved.(Use cd.. to point the current directory path to previous directory and cd dirname to change to the location to your directory where your code is saved if you want to change the drive location then just type drivelocation: and hit enter example D: and use the dir command to list all the files in that directory.)

After changing the current directory location
use this command javac filename.java to compile your java code.
and java file name to compile the code! thats it.

Hello world program to test installation
// Save as “Hello.java”
public class Hello {
public static void main(String[] args) {
System.out.println(“Hello, world!”);
}
}

If you did every step correctly then you get the output of your code!

4 thoughts on “How to Install JDK 7 and Compile Java on Windows 7 and Windows 8

  1. “I had to refresh the page times to view this page for some reason, however, the information here was worth the wait.”

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>