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

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

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

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

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

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

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

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


当前回答

得到广泛好评的答案很好,我已经用了很长一段时间,以这个bat文件的形式:

@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

SET ROOT=%cd%

REM Get the tools.zip from the innards of the installer
7z e *.exe .rsrc/1033/JAVA_CAB10/111
7z e 111 7z x tools.zip
REM Extract all
7z x -aoa tools.zip -ojdk

del tools.zip
del 111

REM Searching directory structure from root for subfolders and zipfiles.
FOR /F "delims==" %%d IN ('dir /ogne /ad /b /s "%ROOT%"') DO (
    echo Descending into %%d
    FOR /F "delims==" %%f IN ('dir /b "%%d\*.pack"') DO (
        echo Extracting "%%d\%%f"
        REM Extract all packs into jars.
        jdk\bin\unpack200 -r  "%%d\%%f" "%%d\%%~nf.jar"
    )
)

ENDLOCAL
pause;

它需要访问7zip的路径,并且必须在你选择的JDK的文件夹中运行(它会找到它,因为上面有*.exe)。

在8u144上也能用,我猜在8u20上也能用。

其他回答

试试这个: http://maven.nuiton.org/nexus/content/repositories/jvm/com/oracle/jre/

此链接包含所有版本的可移植zip发行版。

谢谢关心;JDK似乎不与Windows注册表交互。

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

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

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

阶段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安装程序了

我发现你可以在Wine中运行安装程序。如此:

WINEPREFIX=/home/jason/ jre-7u11-windows-i586.exe

一旦完成,你可以压缩/home/jason/ Java/ drive_c/ program \ Files\ \(x86\)/Java/jre7/

这应该也适用于jdk

不幸的是,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.