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

Discussion in 'Java' started by Karsten Wutzke, May 18, 2007.

  1. 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
    Karsten Wutzke, May 18, 2007
    #1
    1. Advertising

  2. Karsten Wutzke

    Lew Guest

    Karsten Wutzke wrote:
    > - 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?

    --
    Lew
    Lew, May 18, 2007
    #2
    1. Advertising

  3. Karsten Wutzke

    Guest

    On May 18, 6:46 pm, Lew <> wrote:
    > Karsten Wutzke wrote:
    > > - 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?
    >
    > --
    > 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%
    , May 19, 2007
    #3
  4. Karsten Wutzke

    Lew Guest

    wrote:
    > 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.

    --
    Lew
    Lew, May 19, 2007
    #4
  5. On 19 Mai, 00:46, Lew <> wrote:
    > Karsten Wutzke wrote:
    > > - 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%
    >
    > 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
    Karsten Wutzke, May 21, 2007
    #5
  6. Karsten Wutzke

    Guest

    On 21 Mai, 11:18, Karsten Wutzke <> wrote:

    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
    , May 22, 2007
    #6
  7. Karsten Wutzke

    Guest

    On 21 Mai, 11:18, Karsten Wutzke <> wrote:

    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
    , May 22, 2007
    #7
  8. Karsten Wutzke

    Guest

    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
    , May 23, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qy5EaW1pdHJvdg==?=

    StackOverflowException in .NET Runtimes

    =?Utf-8?B?Qy5EaW1pdHJvdg==?=, Jul 25, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,119
    Brock Allen
    Jul 25, 2005
  2. SRussell
    Replies:
    0
    Views:
    296
    SRussell
    Nov 13, 2006
  3. Ulf Meinhardt
    Replies:
    0
    Views:
    597
    Ulf Meinhardt
    Jul 7, 2009
  4. Robin Wenger
    Replies:
    0
    Views:
    2,903
    Robin Wenger
    Aug 18, 2011
  5. Eugene Elborran

    Problem reloading Ruby runtimes

    Eugene Elborran, Mar 23, 2011, in forum: Ruby
    Replies:
    2
    Views:
    108
    Eugene Elborran
    Mar 23, 2011
Loading...

Share This Page