Switching java runtimes (Windows, Ant, Java control panel)

K

Karsten Wutzke

Hello all!

I've been searching for quite some time, but I can't seem to find a
solution...

How do I best switch Java runtimes on a machine where I have JDK 5.0
an 6.0 installed?

My app is made for 5.0 only, but the currently used JRE is always 6.0.
The java.exe in the windows system dir seems to point to the latest
version at all times.

I launch my app from the shell via "ant run" so it is a must that Ant
has to find the "current" JVM. Using absolute paths is not an option
since I use Ant (and will stick to it no matter what).

How do I best switch between JRE's?

Is it possible to switch JRE's without creating a new shell window?

Things that didn't work so far:
- Setting the default JRE via the Java control panel (I haven't found
that anywhere in the dialog...)
- Replacing the PATH entry to the java home dir of 1.5.x
- Setting JAVA_HOME=C:\dev\jdk1.5.0_11\bin
- Adding the jvmversion="1.5" param to Ant's <java> task

I don't want to do any brute-force stuff here.

Maybe someone knows an article that I haven't found so far. Otherwise
I'm all ears...

Karsten
 
L

Lew

Karsten said:
- Replacing the PATH entry to the java home dir of 1.5.x
- Setting JAVA_HOME=C:\dev\jdk1.5.0_11\bin

JAVA_HOME would normally be set to the parent directory of bin/.

set JAVA_HOME=C:\dev\jdk1.5.0_11
PATH=%JAVA_HOME%\bin;%PATH%

If you're starting a program or batch file graphically (double-click) then you
will need to set these envars in the Control Panel System utility.

How exactly are you invoking java?
 
P

printdude1968

JAVA_HOME would normally be set to the parent directory of bin/.

set JAVA_HOME=C:\dev\jdk1.5.0_11
PATH=%JAVA_HOME%\bin;%PATH%

If you're starting a program or batch file graphically (double-click) then you
will need to set these envars in the Control Panel System utility.

How exactly are you invoking java?

He could create a batch file that will switch between them. All he
would have to do is something like (this would be easier on Linux)
if %JAVA_HOME%="C:\dev\jdk1.5.0_11"
then
set JAVA_HOME=other jdk location
endif
PATH=%JAVA_HOME%\bin;%PATH%
 
L

Lew

He could create a batch file that will switch between them. All he
would have to do is something like (this would be easier on Linux)
if %JAVA_HOME%="C:\dev\jdk1.5.0_11"
then
set JAVA_HOME=other jdk location
endif
PATH=%JAVA_HOME%\bin;%PATH%

They would need to remove the old, now-invalid PATH element also.
 
K

Karsten Wutzke

JAVA_HOME would normally be set to the parent directory of bin/.

Oops I had that already...
set JAVA_HOME=C:\dev\jdk1.5.0_11
PATH=%JAVA_HOME%\bin;%PATH%

If you're starting a program or batch file graphically (double-click) then you
will need to set these envars in the Control Panel System utility.

How exactly are you invoking java?

Java is invoked via Ant: "ant run" for example, don't know how Ant
tasks find the JRE...

Anyway I had C:\dev\jdk1.5.0_11\bin on my PATH= var at the second to
last position, now that I put that concrete entry before any
%SYSTEMROOT% (all Windows dirs/subdirs like system32) it works fine
now (only need to recreate a new shell window which is ok for me).

Karsten
 
D

dani.belz

Hi Karten,
Anyway I had C:\dev\jdk1.5.0_11\bin on my PATH= var at the second to
last position, now that I put that concrete entry before any
%SYSTEMROOT% (allWindowsdirs/subdirs like system32) it works fine
now (only need to recreate a new shell window which is ok for me).

that's because in %SYSTEMROOT% you will also find java.exe,
javac.exe, ... I have absolutely no idea why! Took me some time to
figure this out because you would never think about that. Anyway, I
think it's save to remove them. I have JDK 1.4, 5 and 6 installed and
it works perfectly.

-Dani
 
D

dani.belz

Hi Karten,
Anyway I had C:\dev\jdk1.5.0_11\bin on my PATH= var at the second to
last position, now that I put that concrete entry before any
%SYSTEMROOT% (allWindowsdirs/subdirs like system32) it works fine
now (only need to recreate a new shell window which is ok for me).

that's because in %SYSTEMROOT% you will also find java.exe,
javac.exe, ... I have absolutely no idea why! Took my some time to
figure this out because you would never think about that. Anyway, I
think it's save to remove them. I have JDK 1.4, 5 and 6 installed and
it works perfectly.

-Dani
 
I

ilya.khen

Hi,

I do have the same kind of problem with my browser.
JRE 6 and JRE 5 are installed on my machine, but whenever some applet
loads in browser, JRE 6 starts to react. It is good, but what if I
would like to use JRE 5 or JRE 6 by choose?
How to switch between JREs in respect to browser?

-Merlin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top