Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which environment variable decide 'java -version'

 
Yan Bai
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On windows, I installed both j2sdk1.4 and jdk1.5 (1.4 for working, 1.5 for personal)
environmental variables are: PATH as 1.4/bin, JAVA_HOME is where 1.4 is.
so after these, I thought 1.4 is the version of java i am using now, but when i try 'java -version' on command line, 1.5 shows up.
If I disable PATH, 'javac' (compile) won't work, means i am still using 1.4 to compile. however, 'java' works fine.
I guess there's something i should setup as well as PATH and JAVA_HOME. maybe CLASSPATH? I wonder.
Thanks in advance.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Path should be the main thing you need to get going. I have a couple BAT files I use to set JDK paths. By default my command windows don't have a path to a JDK or JRE so I have to run one or the other to get running. Here's one for Java 5:

Hmm, I forgot that sets JAVA_HOME, too. Maybe I needed that for ANT. Once you have the JDK path going, see if this tutorial helps with classpath and all that. Follow the link to the Sun "setting the classpath" page, too.
 
Yan Bai
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found where the problem is.

I have JRE1.5 (not JDK) installed under a different folder than JDK1.5. that's the reason why after PATH is setup to 1.4, 'java -version' still says it's 1.5.

after uninstall JRE, 'java -version' gave what specified in PATH env.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic