Solved

Working between different Java versions

Posted on 2004-10-13
9
211 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now