How to silently install Java JDK into a specific directory on windows

mmo picture mmo · Mar 8, 2013 · Viewed 33.1k times · Source

On my development machine I always have to install Java 6 and Java 7 and I have to install each JDK in both, the 32 and 64 bit version, for testing purposes. Since the frequency of Java updates seems to be getting more and more ridiculous (twice per week by now?) each update requires me to un- and then re-install 4 JDKs. So this is getting really quite annoying and I would thus like to script this entire process.

My problem is, that by default each JDK versions installs into a directory-path that contains the update-number (default: "C:\Program Files\Java\jdk1.6.0_<update-nr>\"). To spare me from having to adapt tons of build-scripts I always manually strip the trailing "_<update-nr>" from the installation path and always install into the same "C:\Program Files\Java\jdk1.6.0" or "C:\Program Files\Java\jdk1.7.0", resp., for the 64-bit versions and into C:\Program Files (x86)\Java\jdk1.6.0" or "C:\Program Files (x86)\Java\jdk1.7.0", resp., for the 32-bit versions.

While I found out, how to specify the installation directory for a JRE installer (i.e. the Java runtime):

<jre-installfile>.exe [/s] [INSTALLDIR=<drive>:\<JRE_install_path>] 
    [STATIC=1] [WEB_JAVA=0/1] [WEB_JAVA_SECURITY_LEVEL=VH/H/M/L]

I did not yet find a similar description how to specify the installation directory for the JDK installer.

Does anyone know if and how one can specify the install path for the JDK installer, so that one can direct a silent JDK installation into a specific installation directory?

Answer

Vivit picture Vivit · Aug 26, 2015

I could successfully install both x64 and x86 versions of JDK 8 update 60 including a public JRE with these commands:

Here JDK 1.8.60 (x86) with source code is going to C:\Java\x86\jdk1.8.0_60 and JRE to C:\Java\x86\jre1.8.0_60:

jdk-8u60-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x86\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x86\jre1.8.0_60

In a similar way, JDK 1.8.60 (x64) with source code is going to C:\Java\x64\jdk1.8.0_60 and JRE to C:\Java\x64\jre1.8.0_60:

jdk-8u60-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x64\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x64\jre1.8.0_60

See Oracle JRE installer options