• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Parameter setting in JDK configuration

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search your hard drive(s) for a file called java.exe. You will find one or more.
 
Ranch Hand
Posts: 97
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Ziyang Zhang
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Marshal
Posts: 79943
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your classpath should be neither a user parameter nor a system parameter. You should set it for each application with the -cp option.
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic