Java 如何以 zip 文件而不是 EXE 或 MSI 安装程序的形式获取最新的 JRE/JDK?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1619662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 17:54:38  来源:igfitidea点击:

How can I get the latest JRE / JDK as a zip file rather than EXE or MSI installer?

javainstallation

提问by opensas

I like to be sure that everything will work just by copying the contents of the Java folder and setting the environment variables.

我希望通过复制 Java 文件夹的内容并设置环境变量来确保一切正常。

I usually run the installer in a virtual machine, zip the \java folder contents, go back to a snapshot of the virtual machine, and then unzip the compressed file.

我通常在虚拟机中运行安装程序,压缩 \java 文件夹的内容,返回虚拟机的快照,然后解压缩压缩文件。

I couldn't find a place where the latest JRE / JDK is available as a zip file...

我找不到以 zip 文件形式提供最新 JRE/JDK 的地方...

http://java.sun.com/javase/downloads/index.jsp

http://java.sun.com/javase/downloads/index.jsp

http://download.java.net/jdk6/

http://download.java.net/jdk6/

Alternately, is it safe to assume that exe installer from sun just will just unzip the whole thing, without messing around with the registry, environment variables, etc...?

或者,是否可以安全地假设来自 sun 的 exe 安装程序只会解压缩整个东西,而不会弄乱注册表、环境变量等......?

Related: Installing Java manually on Windows?

相关:在 Windows 上手动安装 Java?

-- After all this time I found thissite that seems to be exactly what I was looking for (2018-05-22)

-- 过了这么久,我发现这个网站似乎正是我要找的 (2018-05-22)

采纳答案by Maksim Vi.

You can download a Java Portable from PortableApps.com. It will not change your system settings. You can put it on your USB stick.

您可以从PortableApps.com下载 Java Portable。它不会更改您的系统设置。你可以把它放在你的 U 盘上。

UPD: for those who needs JDK there's an open-source project OpenJDK Portable

UPD:对于那些需要 JDK 的人,有一个开源项目OpenJDK Portable

UPD2: there is also a JDK Portable(Oracle)

UPD2:还有一个JDK Portable(Oracle)

Some people might be interested in official Oracle production-ready open source build of JDK

有些人可能对 JDK 的官方 Oracle生产就绪开源构建感兴趣

回答by iokevins

Thanks for asking; the JDK does not seem to interact with the Windows registry.

感谢提问;JDK 似乎不与 Windows 注册表交互。

However, the JRE does in certain instances.

但是,JRE 在某些情况下会这样做。

Link: http://www.rgagnon.com/javadetails/java-0604.html

链接:http: //www.rgagnon.com/javadetails/java-0604.html

回答by Ravi Wallau

I did copy the JRE folder several times and it always works fine. But I am really not sure if you can just get a zip file with its contents, as the official installation install the plugins for IE, Firefox and whatsoever.

我确实多次复制了 JRE 文件夹,但它始终工作正常。但我真的不确定你是否能得到一个包含其内容的 zip 文件,因为官方安装会安装 IE、Firefox 等插件。

回答by Thorbj?rn Ravn Andersen

回答by Igor

JDK is not available as a portable ZIP file, unfortunately. However, you can follow these steps:

不幸的是,JDK 不能作为可移植的 ZIP 文件使用。但是,您可以按照以下步骤操作:

  • Create working JDK directory (C:\JDKin this case)
  • Downloadlatest version of JDK from Oracle (for example jdk-7u7-windows-x64.exe)
  • Downloadand install 7-Zip (or download 7-Zip portableversion if you are not administrator)
  • With 7-Zip extract all the files from jdk-XuXX-windows-x64.exeinto the directory C:\JDK
  • Execute the following commands in cmd.exe:
    • cd C:\JDK\.rsrc\1033\JAVA_CAB10
    • extrac32 111
  • Unpack C:\JDK\.rsrc\1033\JAVA_CAB10\tools.zipwith 7-zip
  • Execute the following commands in cmd.exe:
    • cd C:\JDK\.rsrc\1033\JAVA_CAB10\tools\
    • for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"(this will convert all .packfiles into .jarfiles)
  • Copy all contents of C:\JDK\.rsrc\1033\JAVA_CAB10\toolswhere you want your JDK to be
  • Setup JAVA_HOMEand PATHmanually to point to your JDK dir and its BIN subdirectory.
  • 创建工作 JDK 目录(C:\JDK在本例中)
  • 从 Oracle下载最新版本的 JDK(例如jdk-7u7-windows-x64.exe
  • 下载并安装 7-Zip(如果您不是管理员,请下载7-Zip 便携版)
  • 使用 7-Zip 将所有文件从jdk-XuXX-windows-x64.exe目录中解压缩C:\JDK
  • 在 中执行以下命令cmd.exe
    • cd C:\JDK\.rsrc\1033\JAVA_CAB10
    • extrac32 111
  • C:\JDK\.rsrc\1033\JAVA_CAB10\tools.zip用 7-zip打开包装
  • 在 中执行以下命令cmd.exe
    • cd C:\JDK\.rsrc\1033\JAVA_CAB10\tools\
    • for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"(这会将所有.pack文件转换为.jar文件)
  • 复制C:\JDK\.rsrc\1033\JAVA_CAB10\tools您希望 JDK 所在位置的所有内容
  • 设置JAVA_HOMEPATH手动指向您的 JDK 目录及其 BIN 子目录。

回答by RomelAlvarado

The Process described by Igor and CharlesB Works to me, since IDE's like NetBeans and Eclipse permit specify the location of the JDK, even software like Apache Tomcat (the ZIP Distribution) use BASH - FILES to set it up (then specify the JDK location using relatives URI).
I Have a USB-HardDisk With NetBeans, Eclipse, Apache Tomcat working with a JDK in "portable mode".
I Had a way to extract a copy of the JDK from the installers files: Install it, Copy it in other place and then uninstall it. A dirty way to extract it, but was successfull.
The place to put EXTRA - LIBS was: %PLACE_WHERE_JDK_ARE%\jre\lib\ext

Igor 和 CharlesB 描述的过程对我有用,因为像 NetBeans 和 Eclipse 这样的 IDE 允许指定 JDK 的位置,甚至像 Apache Tomcat(ZIP 分发)这样的软件也使用 BASH - FILES 来设置它(然后使用亲属URI)。
我有一个带有 NetBeans、Eclipse、Apache Tomcat 的 USB 硬盘,可在“便携式模式”下使用 JDK。
我有一种方法可以从安装程序文件中提取 JDK 的副本:安装它,将它复制到其他地方,然后卸载它。一种提取它的肮脏方法,但成功了。
放置 EXTRA - LIBS 的位置是:%PLACE_WHERE_JDK_ARE%\jre\lib\ext

回答by RomelAlvarado

Here is a good, but a little complex, way:

这是一个很好但有点复杂的方法:

Stage 1: MSI & CAB from native installation file

阶段 1:来自本机安装文件的 MSI 和 CAB

  1. Download the JRE or JDK from the Oracle (Sun) website. This method will work on any version and on SDK or JRE.

  2. Run and wait for the installer to load. Minimize the window.

  3. In Windows 7, you should browse to this location:

    C:\Users\ YOUR_USER_NAME\AppData\LocalLow\Sun\Java

  4. There, you will have a few MSI and CAB files.

  1. 从 Oracle (Sun) 网站下载 JRE 或 JDK。此方法适用于任何版本和 SDK 或 JRE。

  2. 运行并等待安装程序加载。最小化窗口。

  3. 在 Windows 7 中,您应该浏览到以下位置:

    C:\Users\ YOUR_USER_NAME\AppData\LocalLow\Sun\Java

  4. 在那里,您将拥有一些 MSI 和 CAB 文件。

enter image description here

在此处输入图片说明

Stage 2: easily extract the MSI & CAB using uniextract

第 2 阶段:使用uniextract轻松提取 MSI 和 CAB

  1. Browse to Universal Extractor | LegRoom.netand download UniExtract Binary Archive.

  2. Use WinRar or any un-RAR program available to you, and extract uniextract161_noinst.raranywhere.

  1. 浏览到通用提取器 | LegRoom.net并下载UniExtract Binary Archive

  2. 使用 WinRar 或任何可用的非 RAR 程序,并在任何地方提取uniextract161_noinst.rar

enter image description here

在此处输入图片说明

Stage 3: finally, extract the inner container named core.zip

第三阶段:最后,提取名为core.zip的内部容器

  1. Drag & drop jdk1.6.0_31.msior jre1.6.0_31.msion the icon of UniExtract.exe.

  2. Select "Extract Method: MSI Administrative Installer". Wait for the process to finish.

  3. Enter the new created folder.

    If you've drag-and-dropped jre1.6.0_31.msiyou should have a jre1.6.0_31folder

  4. Follow all levels inside and you'll see core.zip. enter image description here

  5. This is what you are after. You can just unzip it anywhere and you'll have the content of the Java runtime or SDK without installing anything on your system.

  1. 拖放jdk1.6.0_31.msijre1.6.0_31.msi上的图标UniExtract.exe

  2. 选择“提取方法:MSI 管理安装程序”。等待该过程完成。

  3. 输入新创建的文件夹。

    如果您拖放了jre1.6.0_31.msi,您应该有一个jre1.6.0_31文件夹

  4. 按照里面的所有级别,你会看到core.zip在此处输入图片说明

  5. 这就是你所追求的。您只需将它解压到任何地方,您就可以获得 Java 运行时或 SDK 的内容,而无需在您的系统上安装任何东西。

* You can now close the installer of Java you've left opened in stage 1 *

* 您现在可以关闭在第 1 阶段打开的 Java 安装程序 *

回答by Juancentro

You can just use 7zip (or another similar app) to get the dirs inside the core.zip file that's bundled in the installer. Just use 7zip to browse the exe, you'll see a core.zip file which has all the files that usually go inside "jreX" dir (where X is the major version number). As for setting env variables and the such, you can follow the other answers. If all you want is a portable jre (for example, you can run your jars by using java.exe jarfile or javaw.exe jarfile) then this solution will do. This is very similar to copying the jre dir from one place to another

您可以只使用 7zip(或其他类似的应用程序)来获取安装程序中捆绑的 core.zip 文件中的目录。只需使用 7zip 浏览 exe,您将看到一个 core.zip 文件,其中包含通常位于“jreX”目录中的所有文件(其中 X 是主要版本号)。至于设置环境变量等,您可以按照其他答案进行操作。如果您只需要一个可移植的 jre(例如,您可以使用 java.exe jarfile 或 javaw.exe jarfile 运行您的 jar),那么这个解决方案就可以了。这与将 jre 目录从一个地方复制到另一个地方非常相似

回答by zaki benz

Here is a link for JDK 5 zip file. sun-jdk-5-win32-x86-1.5.0.12.zip

这是 JDK 5 zip 文件的链接。 sun-jdk-5-win32-x86-1.5.0.12.zip

回答by Frank Nocke

This link

这个链接

http://www.java.com/en/download/manual.jsp

http://www.java.com/en/download/manual.jsp

helps you at least avoid the obnoxious preload installer getting straight to the SDK.

至少可以帮助您避免令人讨厌的预加载安装程序直接进入 SDK。

From there, I would install this in a throw-away VM, on your old crufty PC or elsewhere, then transfer the resulting

从那里,我会将它安装在一个废弃的虚拟机中,在你的旧电脑或其他地方,然后传输结果

C:\Program Files (x86)\Java\jre7

(or similar) to your new machine, set the very few usual ENV variables, and there you ideally go, w/o all the marketing junk and potential tie-ins. Of course, also w/o the security from frequent automatic updates.

(或类似)到您的新机器,设置很少的常用 ENV 变量,理想情况下,您可以去那里,没有所有营销垃圾和潜在的搭配。当然,也没有频繁自动更新的安全性。