我希望通过复制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上也能用。

其他回答

Sun JVM可以作为MSI,它可以从脚本执行。

http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/install-msi.html

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

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

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

安装在沙箱,并复制文件夹。

我用exe安装程序安装了JDK 8,然后卸载了JRE,我现在有JDK文件夹,没有env变量或其他设置更改。

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