How to Install Windows JDK Without Running the Installer

Evgeniy Fitsner Software Engineer
3 min read
How to Install Windows JDK Without Running the Installer

Sometimes we want to keep our system as clean as possible and avoid installing JDK from the exe installer. Here is a brief how-to:

Steps

  1. Download JDK from the Oracle website

  2. Install 7-zip if not already installed

  3. Create an unpack.bat file in the same folder as the downloaded JDK installer, with content depending on the JDK version:

Batch file for JDK 8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@echo off
set PATH=%PATH%;C:\Program Files\7-Zip\

rmdir /s /q "%~dp0\jdk-out"
rmdir /s /q "%~dp0\unpacked-jdk"
7z x %1 -o"%~dp0\jdk-out"
cd /d "jdk-out\.rsrc\1033\JAVA_CAB10"
extrac32 111
7z x tools.zip -ojdk
cd /d "jdk"
for /r %%x in (*.pack) do .\bin\unpack200 -r "%%x" "%%~dx%%~px%%~nx.jar"
mkdir "%~dp0\unpacked-jdk"
xcopy /s "%~dp0\jdk-out\.rsrc\1033\JAVA_CAB10\jdk" "%~dp0\unpacked-jdk"
cd /d "%~dp0"
cd /d "jdk-out\.rsrc\1033\JAVA_CAB9"
extrac32 110
xcopy /s "%~dp0\jdk-out\.rsrc\1033\JAVA_CAB9\src.zip" "%~dp0\unpacked-jdk"
cd /d "%~dp0"
rmdir /s /q "%~dp0\jdk-out"

Batch file for JDK 9

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off
set PATH=%PATH%;C:\Program Files\7-Zip\

rmdir /s /q "%~dp0\jdk-out"
rmdir /s /q "%~dp0\unpacked-jdk"
7z x %1 -o"%~dp0\jdk-out"
cd /d "jdk-out"
7z x tools.zip -ojdk
cd /d "jdk"
for /r %%x in (*.pack) do .\bin\unpack200 -r "%%x" "%%~dx%%~px%%~nx.jar"
mkdir "%~dp0\unpacked-jdk"
xcopy /s "%~dp0\jdk-out\jdk" "%~dp0\unpacked-jdk"
cd /d "%~dp0"
rmdir /s /q "%~dp0\jdk-out"
  1. Run the script from the command line with the installer filename as the parameter:
1
unpack jdk-8u152-windows-x64.exe

or

1
unpack jdk-9.0.1_windows-x64_bin.exe

After completing these steps, you will find an unpacked-jdk directory containing the extracted JDK files.