How to extract ONLY the contents of the JDK installer

不想你离开。 提交于 2019-12-03 03:23:09

You can do the installation once and then zip up the installed stuff placed under \Programs\Java.

This can be unzipped elsewhere later and used as a JDK in most IDE's without needing a full reinstall (but then Windows does not know about it)

Here's .bat script for unpacking "pack" files. Must be run in the root of unzipped JDK.

@echo off
echo **********************
echo unpack JDK pack-files
echo **********************
pause

set JAVA_HOME=c:\glassfish4\jdk7

setlocal enableextensions
for /r %%f in (*) do call :process %%f
endlocal
goto :eof

:process
if NOT "%~x1" == ".pack" goto :eof
set FOLDER=%~p1

set PWD=%CD%
pushd %FOLDER%
echo Unpacking %~nx1
%JAVA_HOME%\bin\unpack200.exe %~nx1 %~n1.jar
popd

goto :eof
t0mm13b

I use 7-zip to do that. It seems to handle that installer/self-extracting executables nicely.

I've created cygwin script to do that: https://gist.github.com/4ndrew/f9dca61cedf0e8340b54

#!/bin/sh
# usage example: prepareJdk.sh jdk-7u67-windows-x64.exe (result will be in jdk/)
# Requires: p7zip, unzip

JDK_EXE=$1
7z x -ojdk "$JDK_EXE"
unzip jdk/tools.zip -d jdk/

find jdk/ -type f \( -name "*.exe" -o -name "*.dll" \) -exec chmod u+rwx {} \;

rm jdk/tools.zip
find jdk/ -type f -name "*.pack" | while read eachFile; do
   echo "Unpacking $eachFile ...";
  ./jdk/bin/unpack200.exe $eachFile ${eachFile%.pack}.jar;
  rm $eachFile;
done

You can extract both JDK 1.5 and 1.6 from .exe files, using the Universal Extractor (really a great tool). But don't forget to convert all *.pack files (compressed with Pack200 format) into corresponding *.jar files, in order to obtain a full working environment. You can use the unpack200.exe command provided in the JDK itself.

Thimmayya

Maybe you can try Universal Extractor. The site looks legit, but I haven't tried it myself.

This is e-egiazarov's script, modified to use unpack200.exe from the JDK archive and also to remove the pack file after conversion.

@echo off

setlocal enableextensions
for /r %%f in (*) do call :process %%f
endlocal
goto :eof

:process
if NOT "%~x1" == ".pack" goto :eof
set FOLDER=%~p1

set PWD=%CD%
pushd %FOLDER%
echo Unpacking %~nx1
%PWD%\bin\unpack200.exe %~nx1 %~n1.jar
del %~nx1
popd

goto :eof

a little late to the party

here's an extractor written in powershell

param($installdir)

$list=$(gci -Recurse ./$installdir/*.pack) | %{
    return @{
        source=$_.FullName
        parent=$_.Directory.FullName
        target="$($_.Directory.FullName)\$([io.path]::GetFileNameWithoutExtension($_.Name)).jar"
    }
} | %{
    $result = $(unpack200 $_.source $_.target)
    $_result=$result
    return $_
}

Write-Host $(ConvertTo-Json $list)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!