Link to home
Start Free TrialLog in
Avatar of aratani
aratani

asked on

Working between different Java versions

I have two different java versions installed on my system,

Java 1.4.2
Java 1.5.0

However, when I try to open up the cmd and type in java -version , I get java 1.5.0.

How can I switch to java 1.4.2? I tried to change the Path environment variable to my java 1.4.2 folder, but when I open up the command prompt after that it still gives a java 1.4.2 version?

Is there any registry entry I need to change to get the correct java version in my command prompt? Also, I DON'T want to be using a direct path to the java 1.4.2 code i.e. I DON't want to be doing this,

"C:\Program Files\...\java.exe"

I want to set some variables, so that I can use,

java ...
javac ..

and it would recognize the appropriate version depending on what I've set? This is because I have some .bat files that have many java commands in it, and I need to use the proper version with it.

Thanks for any help. I will increase the points if someone gives me an answer quickly.

AJ
Avatar of zzynx
zzynx
Flag of Belgium image

In a DOS session:

set PATH = C:\Program Files\<your java installation path>;%PATH%;
If you want to set it permanently (for all DOS sessions)
see e.g. http://www.apl.jhu.edu/~hall/java/beginner/settingup.html
Avatar of aratani
aratani

ASKER

As I said earlier, I have tried to set the Path environment variable to my folder, and I tried to open up a DOS session but it still would give me the version 1.5.0 here is a transcript from my DOS session,

C:\Documents and Settings\AJ>path
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec Shared\System;c:\cygwin\bin;c:\cygwin\home\AJ;C:\Program Files\Java\j2sdk1.4.2\bin;c:\python23;c:\ant\bin;

C:\Documents and Settings\AJ>java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

As you can see the path for java is set to C:\Program Files\Java\j2sdk1.4.2\bin;

But the java version still goes to 1.5.0. If I go into the java folder and then do it, it works properly i.e.,

C:\Program Files\Java\j2sdk1.4.2\bin>java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

Any more ideas?

AJ

>>As you can see the path for java is set to C:\Program Files\Java\j2sdk1.4.2\bin;
>>Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Aren't you interchanging the JRE with the JDK?



>>As you can see the path for java is set to C:\Program Files\Java\j2sdk1.4.2\bin;
Try C:\Program Files\Java\j2sdk1.4.2\jre\bin;
ASKER CERTIFIED SOLUTION
Avatar of Breadstick
Breadstick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aratani

ASKER

Breadstick you were right, for some reason I had some java files in c:\windows\system32. That never occured to me. I guess it is placed by Sun in the installation of 1.5.0.

Anyway, I'll increase the points to 200 since you guys answered so fast and I'll split it between both of you. Also, the directories that occured earlier have more precedence.

Thanks

AJ
Thanks for accepting