如何在不安装整个 JDK 的情况下在 Windows 中编译 Java 代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/624950/
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
How can I compile Java code in Windows without installing the whole JDK?
提问by Leonardo
Let's say the runtime environment (version 1.6.0_01-b06) is already in place, but since I lack administrative privileges in this particular PC, the JDK can't be installed. So, is there any portable JDK or standalone Java compiler for Windows that doesn't require installation?
假设运行时环境(版本 1.6.0_01-b06)已经到位,但是由于我在这台特定的 PC 上缺乏管理权限,因此无法安装 JDK。那么,是否有任何不需要安装的适用于 Windows 的可移植 JDK 或独立 Java 编译器?
回答by TofuBeer
You might try taking the tools.jar file from the JDK (you would have to copy it over from another machine) and see if that worked.
您可以尝试从 JDK 中获取 tools.jar 文件(您必须从另一台机器复制它),看看是否有效。
javac is essentially a small exe that starts the VM with the specific class for the compiler.
javac 本质上是一个小 exe,它使用编译器的特定类启动 VM。
Also, there is nothing (that I am aware of) about the JDK install that you couldn't do with a copy of it from another machine. So get on a machine you can install the JDK on, install it, and then copy the files to a place on the machine that you lack the rights to and it should work.
此外,对于 JDK 安装,没有任何(我知道的)是您无法从另一台机器上复制它的。因此,进入一台可以安装 JDK 的机器,安装它,然后将文件复制到机器上您没有权限的地方,它应该可以工作。
回答by Vladimir Dyuzhev
You don't need to install JDK. Just copy it over from another machine, and set PATH to %jdk%/bin and JAVA_HOME to %jdk% (actually, only PATH is often enough). I do it all the time.
您不需要安装 JDK。只需从另一台机器复制它,并将 PATH 设置为 %jdk%/bin 并将 JAVA_HOME 设置为 %jdk%(实际上,通常只有 PATH 就足够了)。我一直这样做。
回答by Vladimir Dyuzhev
Eclipse works very well. being a portable ide, it will use it's own jdk. I personally use jGrasp w/ the jdk's folder as a PATH when I'm trying to write something quick.
Eclipse 运行良好。作为一个便携式ide,它将使用它自己的jdk。当我尝试快速编写一些东西时,我个人使用带有 jdk 文件夹的 jGrasp 作为 PATH。

