Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 567
mmo Avatar asked Mar 08 '13 11:03

mmo


People also ask

Where should JDK be installed on Windows?

The JDK software is installed on your computer, for example, at C:\Program Files\Java\jdk1.


2 Answers

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

like image 161
Vivit Avatar answered Sep 24 '22 13:09

Vivit


I just found this article while searching... it specifies a parameter for INSTALLDIR.

http://makeitfaster.wordpress.com/2011/03/25/java-jdk-silent-install-on-windows/

jdk-7u2-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature" INSTALLDIR="%CD%\jdk7u2"

I unfortunately had already installed on my dev machine, so i couldn't test...

like image 28
Matt Avatar answered Sep 25 '22 13:09

Matt