Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract ONLY the contents of the JDK installer

I just downloaded the Java SDK/JDK versions 5 and 6, and I just need the development tools (and some libraries) contained in the installation packages, I don't need to perform an installation and that's why I was only looking for a zip package at first (for Windows there is only an exe installation file), I only need to extract the contents of the installation packages, I think this can be done from the command line but so far I haven't found how to do this (I already considered WinRar and 7-Zip, but I really want to find how to do it without using these tools)

Have you done this before and how?

like image 958
Abel Morelos Avatar asked Feb 04 '10 23:02

Abel Morelos


2 Answers

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
like image 182
Andrea Scarpino Avatar answered Sep 18 '22 12:09

Andrea Scarpino


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
like image 44
4ndrew Avatar answered Sep 19 '22 12:09

4ndrew