Last active
July 17, 2019 07:50
-
-
Save lhns/aab6ff2df06f9a24b308aa9b43e0e196 to your computer and use it in GitHub Desktop.
Batch script to unpack the jdk installer into a portable jdk folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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