Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Karsten Wutzke - 18 May 2007 15:36 GMT
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
Lew - 18 May 2007 23:46 GMT
> - 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?

Signature

Lew

printdude1968@gmail.com - 19 May 2007 03:40 GMT
> > - Replacing the PATH entry to the java home dir of 1.5.x
> > - Setting JAVA_HOME=C:\dev\jdk1.5.0_11\bin
[quoted text clipped - 11 lines]
> --
> 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%
Lew - 19 May 2007 15:07 GMT
> 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)
[quoted text clipped - 3 lines]
> endif
> PATH=%JAVA_HOME%\bin;%PATH%

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

Signature

Lew

Karsten Wutzke - 21 May 2007 10:18 GMT
> > - 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/.

Oops I had that already...

> set JAVA_HOME=C:\dev\jdk1.5.0_11
> PATH=%JAVA_HOME%\bin;%PATH%
[quoted text clipped - 3 lines]
>
> 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
dani.belz@googlemail.com - 22 May 2007 14:34 GMT
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
dani.belz@googlemail.com - 22 May 2007 17:08 GMT
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
ilya.khen@gmail.com - 23 May 2007 21:50 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.