File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes which environment variable decide 'java -version' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "which environment variable decide Watch "which environment variable decide New topic

which environment variable decide 'java -version'

Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125
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.

SCJP 1.4
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125
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.
I agree. Here's the link:
subject: which environment variable decide 'java -version'
It's not a secret anymore!