如何仅提取 JDK 安装程序的内容

发布于 2024-08-20 11:58:09 字数 227 浏览 5 评论 0原文

我刚刚下载了 Java SDK/JDK 版本 5 和 6,我只需要安装包中包含的开发工具(和一些库),我不需要执行安装,这就是为什么我只寻找 zip首先安装包(对于Windows只有一个exe安装文件),我只需要提取安装包的内容,我认为这可以从命令行完成,但到目前为止我还没有找到如何做到这一点(我已经考虑过 WinRar 和 7-Zip,但我真的想找到如何在不使用这些工具的情况下做到这一点)

您以前做过吗?是如何做到的?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

尬尬 2024-08-27 11:58:09

这是用于解压“pack”文件的 .bat 脚本。必须在解压的 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

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
游魂 2024-08-27 11:58:09

我使用 7-zip 来做到这一点。它似乎可以很好地处理安装程序/自解压可执行文件。

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

软糯酥胸 2024-08-27 11:58:09

我创建了 cygwin 脚本来执行此操作:
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

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
海拔太高太耀眼 2024-08-27 11:58:09

您可以安装一次,然后将安装的内容压缩到 \Programs\Java 下。

稍后可以在其他地方解压缩并在大多数 IDE 中用作 JDK,而无需完全重新安装(但 Windows 不知道这一点)

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)

薯片软お妹 2024-08-27 11:58:09

您可以使用通用提取器(确实是一个很棒的工具)从 .exe 文件中提取 JDK 1.5 和 1.6。但不要忘记将所有 *.pack 文件(以 Pack200 格式压缩)转换为相应的 * .jar 文件,以获得完整的工作环境。您可以使用 JDK 本身提供的 unpack200.exe 命令。

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.

朕就是辣么酷 2024-08-27 11:58:09

也许您可以尝试通用提取器。该网站看起来合法,但我自己还没有尝试过。

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

窝囊感情。 2024-08-27 11:58:09

这是 e-egiazarov 的脚本,已修改为使用来自JDK 存档并在转换后删除包文件。

@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

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
一梦等七年七年为一梦 2024-08-27 11:58:09

聚会有点晚了,

这是一个用 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)

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)
绿萝 2024-08-27 11:58:09

当然,在 7zip 解压的文件夹中,也就是包含 bin 和 lib 文件夹的文件夹中,下面的命令在 Windows 中发挥了“神奇”作用。谢谢。

for /f %f in ('dir /s/b *.pack') do bin\unpack200.exe %~pf%~nxf %~pf%~nf.jar

Being in the folder where it was unzipped by 7zip, the same one that has the bin and lib folders, the command below does the "magic" in Windows, of course. Thanks.

for /f %f in ('dir /s/b *.pack') do bin\unpack200.exe %~pf%~nxf %~pf%~nf.jar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文