[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Working between different Java versions

Posted on 2004-10-13
9
Medium Priority
?
222 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:aratani
  • 6
  • 2
9 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12299545
In a DOS session:

set PATH = C:\Program Files\<your java installation path>;%PATH%;
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12299567
If you want to set it permanently (for all DOS sessions)
see e.g. http://www.apl.jhu.edu/~hall/java/beginner/settingup.html
0
 
LVL 4

Author Comment

by:aratani
ID: 12299628
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:zzynx
ID: 12299672
>>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?



0
 
LVL 37

Expert Comment

by:zzynx
ID: 12299687
>>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;
0
 
LVL 2

Accepted Solution

by:
Breadstick earned 400 total points
ID: 12299731
That's interesting...  The only reason I can see that this might be happening is if you have the 1.5 java.exe somewhere in one of the folders in your path.  Look in C:\WINDOWS or C:\WINDOWS\system32.  I'm not sure which has precedence, the directories that occur earlier in your path, or the directories that occur later.  If it's the directories that occur later, than the 1.5 java.exe must be in your python directory, or your ant\bin directory.

Where is java 1.5 installed to?
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 400 total points
ID: 12299743
>> I'm not sure which has precedence, the directories that occur earlier in your path, or the directories that occur later.
The directories that occur earlier
0
 
LVL 4

Author Comment

by:aratani
ID: 12300412
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
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12305509
Thanks for accepting
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question