java 在cygwin中运行和编译java代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28259282/
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
Run and compile java code in cygwin
提问by Luffy
I just installed cygwin
and I am wondering how do I compile and run my java code through cygwin
?
我刚刚安装cygwin
,我想知道如何编译和运行我的 Java 代码cygwin
?
My java code is at my desktop saved in a file named Java.
我的 Java 代码在我的桌面上保存在一个名为 Java 的文件中。
回答by Jay Zelenkov
Assuming you have Java SDK for Windows installed.
假设您安装了适用于 Windows 的 Java SDK。
In the simplest case:
在最简单的情况下:
Ensure/Add java to PATH in cygwin:
export PATH=$PATH:"/cygdrive/C/Program\ Files/Java/jdk1.8.0_31/bin/"
(don't forget the backslash after Program)
cd
to your desktop:cd /path/to/Desktop
run java compiler:
javac HelloWorld.java
确保/将 java 添加到 cygwin 中的 PATH:
export PATH=$PATH:"/cygdrive/C/Program\ Files/Java/jdk1.8.0_31/bin/"
(不要忘记 Program 后面的反斜杠)
cd
到您的桌面:cd /path/to/Desktop
运行java编译器:
javac HelloWorld.java
In complex projects you will need to provide a bunch or arguments to javac
to make it compile.
在复杂的项目中,您需要提供一堆或参数javac
以使其编译。