Installing
JDK: JDK can be
downloaded from the official site of vendor i.e. Oracle Corporation. As this
JDK is free don’t need to pay any money or charges before downloading or
installing the JKD in your machine.
But remember
JDK is not platform independent and thus you need to choose the correct version
of your OS, to download the compatible version of JDK.
Once you
complete the download, open the destination folder and double click on .exe
file to start the installation of the program. While installing the JDK always
keep in mind that:
i.
You can install
more than one versions of JDK at the same time. For ex. You can install jdk 1.4
and jdk7 at the same time and you can choose which version should be used as
per the requirements.
ii.
You can change the
destination folder to install the jdk. It is not mandatory to install the jdk
in C:\ drive or along with the windows.
Installing jdk is not a difficult process and you are not
required to have any special skills. After installing the jdk you can not
directly execute java programs you have to set up the environment by following
the steps given below.
Setting the path
environment variable in Windows permanently in system:
1. You can
setup the environment variable in two ways. We will first see how to set the
path for javac compiler in your computer’s environment variable list.
2. Click on
‘Start’->the Right click on ‘Computer’ -> From the drop down menu select
the ‘Properties’ option.
3. You might
get different types of windows depending upon the version of the OS you are
using. If you are using Windows 7 or higher then you have to click on ‘Advanced
System settings’ option in the left pane of the system properties window.
4. Then under
the ‘Advanced’ tab you will get option ‘Environment variables’.
5. Click on
the option ‘Environment Variable’.
6. Go to the
installation directory of your jdk. Navigate to the ‘bin’ folder of the jdk
copy the address in the address bar of the window.
7. Now after
choosing the environment variable option click on ‘Edit’ tab. A small window
will be opened with values for ‘Path’ at the end of this current path add ‘;’
(semi-colon) and after that paste the path to bin directory of JDK where it has
been installed on your system.
8. Then click
on ‘OK’ and apply the settings.
9. To view the
whether you have set the path correctly go to command prompt by typing ‘cmd’ in
run menu and type ‘javac’ at the command prompt. If command is executing
successfully, displaying various options to execute the Java program; your path
and environment to create and execute java program is set up successfully.
10. If you are getting message like ‘command
‘javac’ is not found or not valid’ it means that you have not set path
correctly for the ‘bin’ directory of JDK where it is installed.
Why it is required to set the path environment variable to execute java
programs successfully?
Java programs are executed through the
usage of Java compiler and we invoke it by executing ‘javac’ command. Now when
you type ‘javac’ at the command prompt the operating system looks for the
executable ‘javac’ file in the already defined path environment variable. If
system founds then executable ‘javac’ file at the specified location then it
executes the command successfully and if not found it returns the error. This
is the reason behind setting up the path environment variable to execute the
java programs successfully on your computer.
Setting the path
environment variable in Windows with command prompt temporarily:
1. You can
define the separate path environment variable for each command prompt you
start. But this path environment variable is temporary and when you exit the
current command prompt it will be deleted. That is path set at command prompt
will be local to that command prompt only.
2. To see the
current path environment variable type: ‘path’.
3. You will
see the current path for the system. Now to set path type:
‘set path=%path%;’
You are done! Check whether the path environment
variable is set correctly or not by typing ‘javac’ at the command prompt.
0 comments:
Post a Comment