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

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

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

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

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

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

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

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


当前回答

针对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可移植非常有用。: -)

其他回答

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

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

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

下面提示中的命令包装为批处理脚本。保存为unpack.bat。然后将它与jdk/jre提取文件一起放置到dir。

@echo off

cd /d "%~dp0"
for /r %%x in (*.pack) do .\bin\unpack200 -r "%%x" "%%~dx%%~px%%~nx.jar"

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