Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Working between different Java versions

Posted on 2004-10-13
9
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

636 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