Dashboard > Hippo CMS > ... > Installing > Switching between JDKs
Switching between JDKs
Added by Mathijs Brand, last edited by Mathijs Brand on Sep 04, 2007  (view change)
Labels: 


Windows

With two batch files it is very easy to switch between two different JDK versions, e.g. 1.4.2 and 1.5.0:

jdk14.bat

@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\j2sdk1.4.2_12
echo setting PATH
set PATH=C:\j2sdk1.4.2_12\bin;%PATH%
echo Display java version
java -version

jdk5.bat

@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_12
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.5.0_12\bin;%PATH%
echo Display java version
java -version

Automatically choose JDK when opening command line

For convenienve, you can create different shortcuts for opening command lines with different JDKs.

  1. Right click on your shortcut for opening a command line
  2. Choose tab "Shortcut"
  3. In field "Target", add the option /k name-of-batch-file at the end, e.g.
    %windir%\system32\cmd.exe /k jdk14
    

    Make sure the batch file is either in the directory you open the command line in, or in the PATH.

  4. Click "OK"! Done!

Listen very carefully, I shall say this only once 1

JAVA_HOME and the path to java must always refer to the exact same version of the JDK. If you mix them up, unpredictable things will happen!

Be careful with switching between different JDK versions. Always check which version you are using before deploying artifacts to a Maven repository.

When installing Java, binaries will also be placed in C:\WINDOWS\SYSTEM32. These might overrule the ones in your JAVA_HOME\bin directory, depending on your path.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.7 Build:#813 Aug 28, 2007) - Bug/feature request - Contact Administrators