Skip to content

Instantly share code, notes, and snippets.

@lhns
Last active July 17, 2019 07:50
Show Gist options
  • Save lhns/aab6ff2df06f9a24b308aa9b43e0e196 to your computer and use it in GitHub Desktop.
Save lhns/aab6ff2df06f9a24b308aa9b43e0e196 to your computer and use it in GitHub Desktop.
Batch script to unpack the jdk installer into a portable jdk folder
@echo off
set jdkinstaller=%1
for /F "tokens=* USEBACKQ" %%F in (`powershell -Command "'%jdkinstaller%' -replace '.*(?:\\|/)jdk-(\d)u(\d+)-.*','jdk1.$1.0_$2'"`) do (
set jdkpath=%%F
)
set PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip
echo Unpacking %jdkinstaller% to %jdkpath%
mkdir .%jdkpath%
cd .%jdkpath%
7z e %jdkinstaller% .rsrc/1033/JAVA_CAB*/*>NUL:
for /F "tokens=* USEBACKQ" %%F in (`dir /B`) do (
7z e %%F>NUL:
del %%F
)
echo Unpacking jdk
7z x tools.zip>NUL:
del tools.zip
echo Unpacking jars
for /r %%x in (*.pack) do (
.\bin\unpack200 -r "%%x" "%%~dx%%~px%%~nx.jar"
)
cd ..
rem rmdir /S /Q %jdkpath%
ren .%jdkpath% %jdkpath%
echo Finished
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment