aspose file tools*
The moose likes Beginning Java and the fly likes Parameter setting in JDK configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parameter setting in JDK configuration " Watch "Parameter setting in JDK configuration " New topic
Author

Parameter setting in JDK configuration

Ziyang Zhang
Ranch Hand

Joined: Jul 17, 2010
Posts: 47
Hi,
I am not a beginner. I used java for 3 years.
But I have never made the JDK installation clear in my mind. What a SHAME!!!
I make install JDK and make it works.
I hope people who really truly understand this could help me out.
But I still have some questions:
1. Should path be “User Parameter” or “System Parameter”?
2. Should classpath be “User Parameter” or “System Parameter”?
3. Should JAVA_HOME be “User Parameter” or “System Parameter”?
4. I found if I set JAVA_HOME as “User Parameter” and set path as “System Parameter” (I use JAVA_HOME when setting path). This will not work, which means % JAVA_HOME % in path could not be interpreted. WHY? If I set both JAVA_HOME and path as “System Parameter”, it works.
5. I think Java –version could not be used as a test to see if JDK is installed successfully. I installed 1.6.21 without setting path. When I use java –version, it works but it says 1.6.22. Obviously, this comes from somewhere else in my computer. But if I use javac directly, it doesn’t work. After I set path, javac works.

Enjoy life!
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Ziyang Zhang wrote:...I found if I set JAVA_HOME as “User Parameter” and set path as “System Parameter” (I use JAVA_HOME when setting path). This will not work, which means % JAVA_HOME % in path could not be interpreted. WHY? If I set both JAVA_HOME and path as “System Parameter”, it works...

As Tom pointed out, a system parameter is always available, regardless of what user account is logged in. In contrast, a user parameter is only available if that particular account is being used.

With that in mind, if PATH is updated as a sytem parameter (available to all accounts) but it includes JAVA_HOME, which is defined as a user parameter (only available to one account)... Do you see the problem?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ziyang Zhang
Ranch Hand

Joined: Jul 17, 2010
Posts: 47
Thank you very much for your answer!! I think the system should interpret JAVA_HOME when I log in if my "user parameter" is set. Anyway, I'm not the guy who design windows:-)
Thanks a lot!

marc weber wrote:
Ziyang Zhang wrote:...I found if I set JAVA_HOME as “User Parameter” and set path as “System Parameter” (I use JAVA_HOME when setting path). This will not work, which means % JAVA_HOME % in path could not be interpreted. WHY? If I set both JAVA_HOME and path as “System Parameter”, it works...

As Tom pointed out, a system parameter is always available, regardless of what user account is logged in. In contrast, a user parameter is only available if that particular account is being used.

With that in mind, if PATH is updated as a sytem parameter (available to all accounts) but it includes JAVA_HOME, which is defined as a user parameter (only available to one account)... Do you see the problem?
Ziyang Zhang
Ranch Hand

Joined: Jul 17, 2010
Posts: 47
Tom Reilly wrote:I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.

Thanks a lot!!! Do you have any idea why java -version works all the time no matter if I install jdk or not?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Search your hard drive(s) for a file called java.exe. You will find one or more.
Gaurav Sagar
Ranch Hand

Joined: Sep 08, 2010
Posts: 97

Ziyang Zhang wrote:
Tom Reilly wrote:I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.

Thanks a lot!!! Do you have any idea why java -version works all the time no matter if I install jdk or not?


java -version works because that is an executable always present in the jre (Java Run time Environment) which is shipped to you when you buy your windows OS. When you install the JDK then JRE is also installed(if you don't have a JRE or your JRE previously installed is of an older version).

So, to check the proper installation of your JDK i.e. after you have set the path, then simply enter the javac -version onto your command prompt. This would tell you the version of javac installed onto your system. It's far better to use then getting confused by the java -version(Highly Recommended).


SCJP 1.6(91%), SCWCD 1.5(100%), SCBCD in progress
Ziyang Zhang
Ranch Hand

Joined: Jul 17, 2010
Posts: 47
Gaurav Sagar wrote:
Ziyang Zhang wrote:
Tom Reilly wrote:I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.

Thanks a lot!!! Do you have any idea why java -version works all the time no matter if I install jdk or not?


java -version works because that is an executable always present in the jre (Java Run time Environment) which is shipped to you when you buy your windows OS. When you install the JDK then JRE is also installed(if you don't have a JRE or your JRE previously installed is of an older version).

So, to check the proper installation of your JDK i.e. after you have set the path, then simply enter the javac -version onto your command prompt. This would tell you the version of javac installed onto your system. It's far better to use then getting confused by the java -version(Highly Recommended).


This is very clear. Thank you so much!!!
I have a folder called jre under my jdk install directory. And I also has jre under C:\Program Files\Java.
In my understanding jre under C:\Program Files\Java is used for run some 'real' java program in my system or browser. For example, if there is a applet, this will run in the jre under C:\Program Files\Java.
What is the jre under jdk for???
Thanks a LOT!!!
Ziyang
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Your classpath should be neither a user parameter nor a system parameter. You should set it for each application with the -cp option.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parameter setting in JDK configuration