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

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

我找不到一个地方有最新的JRE / JDK压缩文件…

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

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

另外,假定sun的exe安装程序只是解压缩整个文件,而不会弄乱注册表、环境变量等等,这是否安全?

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

-- 经过这么长时间,我找到了这个网站,似乎正是我要找的(2018-05-22)


当前回答

对于JDK 8u102,事情已经发生了变化,这对我来说是有效的:

下载windows JDK exe 用7-Zip打开 将内容转储到%JDK-EXE%目录中 cmd: cd %JDK-EXE%.rsrc\1033\JAVA_CAB10 命令:extrac32 111 现在在目录中有一个tools.zip,用7-Zip打开它 将内容提取到一个新目录%JDK-VERSION% cmd: cd %JDK-VERSION% cmd: / r % x (* .pack)。\ bin \ unpack200 - r“% x”“% ~ dx % ~ px % ~ nx.jar” src.zip在%JDK-EXE%中。rsrc\1033\JAVA_CAB9\110\ -拷贝到%JDK-VERSION%

现在你已经准备好了。 您可能希望将JAVA_HOME和PATH设置为指向%JDK-VERSION% dir及其BIN子目录。

其他回答

答案之前已经给出了。它也适用于“jdk-8u91-windows-x64.exe”

用7-zip解压,得到tools.zip 解压tools.zip到一个文件夹folder_name,这样我们就可以得到图片中的内容 在cmd下,移动到文件夹“folder_name/bin”,执行该命令 java - version

输出将是

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

这表明有什么东西搞砸了。事实上,我们需要打开所有的包裹。

在cmd中移动到文件夹folder_name,并通过执行命令自动进行解压 在(x / r % * .pack)。\ bin \ unpack200 - r“% x”“% ~ dx % ~ px % ~ nx.jar” 再次执行第3步,如果得到如下所示的输出,那么JDK就可以使用了。


java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode)

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

针对Windows x86、Windows x64、Linux x86、Linux x64、Mac OS X x64、Solaris x64等操作系统,Oracle网站上有JRE的.tar.gz文件。 参见:http://www.oracle.com/technetwork/java/javase/downloads/jre8 -下载- 2133155. - html

还有Java开发工具包(JDK): http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html。 Windows .tar.gz。没有,但是您可以用7zip之类的工具提取.exe文件。

我发现这对于使Eclipse可移植非常有用。: -)

这里有一个好方法,但有点复杂:

阶段1:MSI和CAB从本地安装文件

请从Oracle (Sun)网站下载JRE或JDK。此方法适用于任何版本和SDK或JRE。 运行并等待安装程序加载。最小化窗口。 在Windows 7中,你应该浏览到这个位置: C:\Users\ YOUR_USER_NAME \AppData\LocalLow\Sun\Java 在那里,您将有一些MSI和CAB文件。

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

浏览到Universal Extractor | LegRoom.net并下载UniExtract二进制档案。 使用WinRar或任何可用的unrar程序,并在任何地方提取uniextract161_noinst.rar。

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

拖放jdk1.6.0_31。Msi或jre1.6.0_31。在UniExtract.exe的图标上打开msi。 选择“提取方法:MSI管理安装程序”。等待过程结束。 输入新创建的文件夹。 如果您已经拖放了jre1.6.0_31。Msi你应该有一个jre1.6.0_31文件夹 遵循所有级别,您将看到core.zip。 这就是你所追求的。您可以在任何地方解压缩它,这样就有了Java运行时或SDK的内容,而无需在系统上安装任何东西。

你现在可以关闭在第一阶段打开的Java安装程序了

不幸的是,JDK不能作为可移植的ZIP文件提供。但是,你可以遵循以下步骤:

Create working JDK directory (C:\JDK in this case) Download latest version of JDK from Oracle (for example jdk-7u7-windows-x64.exe) Download and install 7-Zip (or download 7-Zip portable version if you are not administrator) With 7-Zip extract all the files from jdk-XuXX-windows-x64.exe into 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.zip with 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 .pack files into .jar files) Copy all contents of C:\JDK\.rsrc\1033\JAVA_CAB10\tools where you want your JDK to be Setup JAVA_HOME and PATH manually to point to your JDK dir and its BIN subdirectory.