windows 用于生成 .exe 文件的 Java 编译器选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53845/
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
Java Compiler Options to produce .exe files
提问by ramayac
What compiler (I'm using gcj 4.x) options should I use to generate an "exe" file for my java application to run in windows?
我应该使用什么编译器(我使用的是 gcj 4.x)选项来为我的 Java 应用程序生成一个“exe”文件以在 Windows 中运行?
回答by Bill the Lizard
To compile the Java program MyJavaProg.java, type:
要编译 Java 程序 MyJavaProg.java,请键入:
gcj -c -g -O MyJavaProg.java
To link it, use the command:
要链接它,请使用以下命令:
gcj --main=MyJavaProg -o MyJavaProg MyJavaProg.o
and then linking to create an executable mycxxprog.exe
然后链接以创建可执行文件 mycxxprog.exe
g++ -o mycxxprog.exe mycxxprog.o