简体   繁体   中英

how do i create a .exe that runs a java program?

我有一个非常基本的Java程序,只是一个.java / .class文件(我猜是.java未编译的.class编译的),我如何制作可以在其他计算机上运行的东西?

This sort of kills the very purpose of Java (portability of the language), so you should always try to use the files compiled as .jar, since most of the computers out there (especially Windows and Macs) do have a Java Virtual Machine.

If you really need to compile something down to exe, you should be interested in Ahead-of-Time compilers (AOT), one of them being the GNU Compiler for Java .

There are tools like NativeJ that will let you bundle a JRE, but obviously your executable is going to be much larger if you do that. Usually Java programs are just distributed as JAR files , which are just zip archives of the class files with a manifest

看一下这个问题的答案。

You can use a tool like IzPack2exe . Even if you package the the program just as a jar file - double clicking it in windows win run it, if the user has Java installed.

For Java you usually build a jar file. You can simply execute it by double-clicking on it. It's basically a Zip file with some metadata and another name (yes, zip files don't have enough names already). Check out the jar tool that comes with your JDK. A Java IDE should also have the option to create such a thing.

You can also use NSIS. You can find an example of slightly better application launcher .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM