After installing java and knowing the directory structure its time to prepare the system for compilation and execution of java programs.
To achieve this, we need to follow following steps:
- From the desktop, right click the Computer icon.
- Choose Properties from the context menu
Click the Advanced system settings link.
look into the User variables option and click on new..(not shown in pic)there it ask for the variable name and variable value
write in :
variable name : JAVA_HOME
variable value : <path of java installation root directory>
like if you have installed java in "c" Drive and java as separate folder then you need to write
C:\Java\jdk1.7.0_45 for variable value.
now look into System variables and click on Path variable name then click on Edit and there in variable value option write in <C:\Java\jdk1.7.0_45\bin> that is path to bin folder of installed jdk or we can also write %JAVA_HOME%\bin
The
PATH
environment variable is a series of directories separated by semicolons (;
). Microsoft Windows looks for programs in the PATH
directories in order, from left to right. You should have only one bin
directory for the JDK in the path at a timeNow after setting these configuration you can check the java installation as follows:
- go to command prompt
- then write java -version
- if you have done it correctly you will be getting following
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
If you have not done it correctly it will show different message and need to check the settings again and for that you can refer my another post:http://learntechnolgy.blogspot.in/2013/11/getting-started-with-java.html
After completing all these configuration work, some curious mind must be thinking what is this all about ? why we do this? can there be another option? like this many other questions.....
I am going to write some answers , may be it help those curious mind.
As soon as we click on the Environment Variables option a new window open with name System Properties (where we set different variables and Path).
so as the name suggest we just set or come to know about different Properties of our system.
Think in different way, we have installed java on our system, now, how our system will come to know that java is in the system or how our system will execute different .exe file shipped with jdk installation. so to let these happen we need to tell our system and for that we set different variables and values and path in System properties option.(apart from that there are also more concepts linked with .dll file that i will explain in coming posts).
In more technical way we can say:
Setting the
PATH
environment variable will let us to conveniently run the executable (javac.exe
, java.exe
, javadoc.exe
, and so on) from any directory without having to type the full path of the command.
setting the path variable let it persist in system after rebooting also.
If you do not set the
PATH
variable, you need to specify the full path to the executable every time you run it, such as:
C:\Java\jdk1.7.0\bin\javac ABC.java
No comments:
Post a Comment