Solved

Working between different Java versions

Posted on 2004-10-13
9
216 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 100 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 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

691 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