在 Windows 上手动安装 Java?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/930265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Java manually on Windows?
提问by sachin
I have seen many products bundeled with JDK, I wonder if there is a way where one can install JDK by simply unzipping contents to a directory, so there is no icon created in add/remove programs, no registry entries etc.
我见过许多与 JDK 捆绑在一起的产品,我想知道是否有一种方法可以通过简单地将内容解压缩到目录来安装 JDK,因此在添加/删除程序中没有创建图标,没有注册表项等。
Also in this case: How can we configure Java plugin for browsers? And how can we configure settings as seen via Control Panel entry for Java?
同样在这种情况下:我们如何为浏览器配置 Java 插件?我们如何通过 Java 的控制面板条目配置设置?
采纳答案by Bob Cross
Yes, you can create a zipped up JDK, unzip it on the target machine and run java, javac, etc. from that directory to your heart's content.
是的,您可以创建一个压缩的 JDK,将其解压缩到目标机器上,然后从该目录运行 java、javac 等,直到您满意为止。
The easiest way to create such a zip file is to install the JDK on a machine and then zip up the contents of the JDK directory. We do this in certain circumstances where we need to control exactly what configuration of Java will be used in our deployments. In that case, our scripts just point JAVA_HOME (or the equivalent) to our internally bundled JDK instead of relying on a sysadmin to install exactly what we need prior to arrival.
创建此类 zip 文件的最简单方法是在机器上安装 JDK,然后压缩 JDK 目录中的内容。我们在某些需要精确控制部署中使用的 Java 配置的情况下会这样做。在这种情况下,我们的脚本只是将 JAVA_HOME(或等效的)指向我们内部捆绑的 JDK,而不是依赖系统管理员在到达之前准确安装我们需要的东西。
In terms of integrating with the browsers, that can be a bit more problematic. The short answer is no, you can't integrate directly with the browser without somesort of installer.
在与浏览器集成方面,这可能会有点问题。简短的回答是否定的,你不能直接用浏览器,而整合一些类型的安装程序。
回答by Charlie Martin
Really, no, at least if you want to use it from Windows and not from, say, cygwin. Windows depends too much on the registry; you could simulate the registry updates necessary, but software that moves the files to the right place and updates the registry is called "an installer"; you'd just be reinventing the installer.
真的,不,至少如果您想从 Windows 而不是从 cygwin 使用它。Windows 过于依赖注册表;您可以模拟必要的注册表更新,但是将文件移动到正确位置并更新注册表的软件称为“安装程序”;你只是在重新发明安装程序。
回答by Jon Skeet
I believe this at least used to be feasible to a limited extent with earlier versions of Java - I don't know if it still is.
我相信这至少在早期版本的 Java 中在有限程度上是可行的 - 我不知道它是否仍然可行。
Most of the registry entries are used for things like browser plugins, as you mentioned in the question. If you justwant to be able to run Java (e.g. from a batch file), that's one thing - but really installingit is a different matter. Even if you're just wanting to run it, you'll need to be careful to always explicitly use the one you intend, rather than using the installed one accidentally for part of your application.
正如您在问题中提到的,大多数注册表项都用于浏览器插件之类的东西。如果您只想能够运行 Java(例如从批处理文件),那是一回事 - 但真正安装它是另一回事。即使您只是想运行它,您也需要小心始终明确地使用您打算使用的那个,而不是将已安装的意外用于您的应用程序的一部分。
What's your actual use case? Do you actually need a browser plugin? What aspect of the configuration are you interested in? A lot of the control panel configuration is to do with updates and browser integration. Many other aspects can be controlled using command line options to set specific system properties.
你的实际用例是什么?你真的需要浏览器插件吗?您对配置的哪个方面感兴趣?许多控制面板配置与更新和浏览器集成有关。许多其他方面可以使用命令行选项来控制以设置特定的系统属性。
回答by adrian.tarau
If you just want to provide a JVM with your application is fine, but more than that I would not recommend.
如果你只是想为你的应用程序提供一个 JVM 很好,但我不推荐更多。
回答by David Taylor
You could use SysInternals RegMon and FileMon (now owned and dist by MS) to see exactlywhat is modified by the Java installer. I believe there will be a number of reg entries that you will want to create. Products like WISE installer, for example, also use this sort of approach under the hood to repackage product installations (e.g. as MSI).
您可以使用 SysInternals RegMon 和 FileMon(现在由 MS 拥有和分发)来准确查看Java 安装程序修改的内容。我相信您会想要创建许多 reg 条目。例如,像 WISE 安装程序这样的产品也在幕后使用这种方法来重新打包产品安装(例如作为 MSI)。
Please be carefulsince there are also some dynamicdecisions made by the installer which may affect what gets installed (e.g. on XP v.s. W2K3 server). I was bitten by this once regarding installed codepages. I do not recall the precise details, but the effect was that a codepage file was missing in my embedded JRE + JDK (legally redistributable portion only). This caused a very bizarre and seemingly nonsensical runtime error in my code. It goes without saying that the same applies to Server v.s. client JVM DLLs.
请小心,因为安装程序还会做出一些动态决定,这可能会影响安装的内容(例如,在 XP 与 W2K3 服务器上)。关于已安装的代码页,我曾经被这件事咬过。我不记得确切的细节,但结果是我的嵌入式 JRE + JDK(仅限合法可再发行部分)中缺少代码页文件。这在我的代码中导致了一个非常奇怪且看似荒谬的运行时错误。不用说,这同样适用于服务器与客户端 JVM DLL。
回答by BetaRide
If you just want to have the JDK (JRE) files, you can run the installer within sandboxie. Once installed in the sandbox, just copy the files from c:\sandbox
and you are done.
如果您只想拥有 JDK (JRE) 文件,您可以在sandboxie 中运行安装程序。一旦安装在沙箱中,只需从中复制文件即可c:\sandbox
。
I'm using this to compile and run legacy java applications which cannot be migrated easily to a newer version of java. I can point Eclispe to this JDKs and tell it to be compliant to Java 1.3.
我正在使用它来编译和运行无法轻松迁移到较新版本的 Java 的遗留 Java 应用程序。我可以将 Eclispe 指向这个 JDK 并告诉它符合 Java 1.3。
回答by rtconner
Just down load the Windows server version of Java from the Oracle downloads page. Setup JAVA_HOME and PATH variables on your own.
只需从 Oracle 下载页面下载 Windows 服务器版本的 Java。自行设置 JAVA_HOME 和 PATH 变量。
回答by Edison
According to this, I created a batch scriptto build jdk archives automatically.
The essential parts of the link are:
链接的基本部分是:
- Create working JDK directory ("C:\JDK" in this case)
- Download latest version of JDK from oracle (for example "jdk-7u7-windows-i586.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-[6-7]u?-windows-i586.exe" in directory "C:\JDK"
- In command shell (cmd.exe) do the following:
- change directory to directory C:\JDK.rsrc\JAVA_CAB10
- execute command: extrac32 111
- Unpack C:\JDK.rsrc\JAVA_CAB10\tools.zip with 7-zip
- In command shell (cmd.exe) do the following:
- change directory to C:\JDK.rsrc\JAVA_CAB10\tools\
- execute command: for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"(this will convert all pack files into jar)
- Copy whole directory and all subdir of c:\JDK.rsrc\JAVA_CAB10\tools" where you want your JDK to be and setup manually JAVA_HOME and PATH to point to your JDK dir and its BIN subdir.
- 创建工作 JDK 目录(在本例中为“C:\JDK”)
- 从 oracle 下载最新版本的 JDK(例如“jdk-7u7-windows-i586.exe”)
- 下载并安装 7-zip(如果您不是管理员,请下载 7-zip 便携版)
- 使用 7-zip 从目录“C:\JDK”中的“jdk-[6-7]u?-windows-i586.exe”中提取所有文件
- 在命令外壳 (cmd.exe) 中执行以下操作:
- 将目录更改为目录 C:\JDK.rsrc\JAVA_CAB10
- 执行命令:extract32 111
- 用 7-zip 解压 C:\JDK.rsrc\JAVA_CAB10\tools.zip
- 在命令外壳 (cmd.exe) 中执行以下操作:
- 将目录更改为 C:\JDK.rsrc\JAVA_CAB10\tools\
- 执行命令:for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"(这会将所有包文件转换为 jar)
- 复制整个目录和 c:\JDK.rsrc\JAVA_CAB10\tools" 的所有子目录,你希望你的 JDK 和手动设置 JAVA_HOME 和 PATH 指向你的 JDK 目录和它的 BIN 子目录。