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

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

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

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

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

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

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

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


当前回答

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

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

其他回答

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

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

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

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

这应该也适用于jdk

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

下载javase和JDK

jdk从Oracle网站http://www.oracle.com/technetwork/java/javase/downloads/index.html下载 解压缩exe。例如:jdk-8u5-windows-x64.exe 将以下文件:tools.zip(在解压缩文件夹下找到)解压缩到所需的JAVA_HOME。 更新JAVA_HOME环境变量以指向所需的路径。

测试版本:jdk-7u60-windows-x64.exe, jdk-7u60-windows-x64.exe

下载javaee和JDK

jdk从Oracle网站http://www.oracle.com/technetwork/java/javaee/downloads/index.html下载 解压缩exe。例如:jdk-7u55-windows-x64.exe Product\Packages\jdk.zip(在解压缩文件夹下找到)解压缩到所需的JAVA_HOME。 更新JAVA_HOME环境变量以指向所需的路径。

已测试版本:jdk-7u55-windows-x64.exe

对于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子目录。