Skip to content

Instantly share code, notes, and snippets.

@giseongeom
Last active March 23, 2017 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giseongeom/ce47435dffd13f0880957903d35ac383 to your computer and use it in GitHub Desktop.
Save giseongeom/ce47435dffd13f0880957903d35ac383 to your computer and use it in GitHub Desktop.
jdkextract - Extract JDK files from oracle distribution without install
@echo off
SETLOCAL
IF #%1# == ## (
GOTO :usage
) ELSE (
GOTO :main
)
:main
SET TMP_TARGET=TMP_%~n1
SET TARGET=%~dp1%~n1
REM 7z found?
where /Q 7z || ( echo "7z not found, So exiting..." && exit /B 999 )
REM Delete file(s)/folder(s) from previous attempts
if exist %TMP_TARGET% rd /s /q %TMP_TARGET%
if exist %TARGET% rd /s /q %TARGET%
REM extract jdk
7z x -bd -o%TMP_TARGET% %~f1 > nul
pushd %TMP_TARGET%\.rsrc\1033\JAVA_CAB10
extrac32 111
7z x -otools tools.zip > nul
cd tools
for /r %%x in (*.pack) do .\bin\unpack200 -r "%%x" "%%~dx%%~px%%~nx.jar"
xcopy *.* %TARGET%\ /e /y /q > nul
popd
rd /s /q %TMP_TARGET%
goto :end
:usage
echo ---------------------------------------------------------------------
echo # Filename: %0
echo # Usage: %0 jdk-8u121-windows-x64.exe
echo #
echo #
echo ---------------------------------------------------------------------
GOTO :end
:end
ENDLOCAL
@giseongeom
Copy link
Author

HOW TO RUN

  • Download Oracle JDK (e.g jdk-8u121-windows-x64.exe)
  • jdkextract jdk-8u121-windows-x64.exe
C:\temp>dir
 Volume in drive C is OS
 Volume Serial Number is F69A-3638

 Directory of C:\temp

03/23/2017  05:29 PM    <DIR>          .
03/23/2017  05:29 PM    <DIR>          ..
03/23/2017  12:04 AM       205,004,856 jdk-8u121-windows-x64.exe
               1 File(s)    205,004,856 bytes
               2 Dir(s)  745,436,766,208 bytes free

C:\temp>jdkextract jdk-8u121-windows-x64.exe

C:\temp>dir jdk-8u121-windows-x64\
 Volume in drive C is OS
 Volume Serial Number is F69A-3638

 Directory of C:\temp\jdk-8u121-windows-x64

03/23/2017  05:29 PM    <DIR>          .
03/23/2017  05:29 PM    <DIR>          ..
03/23/2017  05:29 PM    <DIR>          bin
03/23/2017  05:29 PM    <DIR>          db
03/23/2017  05:29 PM    <DIR>          include
12/13/2016  05:06 AM         5,094,117 javafx-src.zip
03/23/2017  05:29 PM    <DIR>          jre
03/23/2017  05:29 PM    <DIR>          lib
12/13/2016  11:45 AM                40 LICENSE
12/13/2016  11:45 AM               159 README.html
12/13/2016  11:45 AM               528 release
12/13/2016  05:06 AM           110,114 THIRDPARTYLICENSEREADME-JAVAFX.txt
12/13/2016  11:45 AM           177,094 THIRDPARTYLICENSEREADME.txt
               6 File(s)      5,382,052 bytes
               7 Dir(s)  745,081,712,640 bytes free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment