如何仅提取 JDK 安装程序的内容
我刚刚下载了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
这是用于解压“pack”文件的 .bat 脚本。必须在解压的 JDK 的根目录中运行。
Here's .bat script for unpacking "pack" files. Must be run in the root of unzipped JDK.
我使用 7-zip 来做到这一点。它似乎可以很好地处理安装程序/自解压可执行文件。
I use 7-zip to do that. It seems to handle that installer/self-extracting executables nicely.
我创建了 cygwin 脚本来执行此操作:
https://gist.github.com/4ndrew/f9dca61cedf0e8340b54
I've created cygwin script to do that:
https://gist.github.com/4ndrew/f9dca61cedf0e8340b54
您可以安装一次,然后将安装的内容压缩到 \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)
您可以使用通用提取器(确实是一个很棒的工具)从 .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.
也许您可以尝试通用提取器。该网站看起来合法,但我自己还没有尝试过。
Maybe you can try Universal Extractor. The site looks legit, but I haven't tried it myself.
这是 e-egiazarov 的脚本,已修改为使用来自JDK 存档并在转换后删除包文件。
This is e-egiazarov's script, modified to use
unpack200.exe
from the JDK archive and also to remove the pack file after conversion.聚会有点晚了,
这是一个用 powershell 编写的提取器
a little late to the party
here's an extractor written in powershell
当然,在 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