我在 Eclipse 中完成了我的项目。我的Eclipse 工作区中有*.java
、.project
和文件。如何创建可执行文件?现在。.classpath
*.class
6 回答
Eclipse will build an executable jar file for you, which is run with Java (java.exe if you're on windows) to launch your application. On a machine correctly set up with Java installed, double clicking an executable jar should run the program.
If you want an exe, then there are ways to do it that will generally wrap the jar file (and sometimes the JDK.) However, first ask yourself why you're doing it this way - often it's just a habitual desire to have an exe, without any great technical reason. All you're really doing through this is taking a cross-platform executable, and making it only work on Windows.
If you're distributing your application and your users expect an exe, then consider building platform dependant installers for each OS you wish to support, but leaving the jar file in tact. The average user will never usually need to touch it directly if your installer places shortcuts in the correct locations, they'll only ever need to run the installer directly (so your application file format becomes irrelevant, just an implementation detail as far as they're concerned.)
You need to create a .jar file from your project. On windows normally with double click those files get executed if a java virtual machine is installed.
There are solutions to wrap an .exe file around your .jar, but I don't know how good they are so I can't suggest anything.
Java executables are runnable .JAR files. You need to export as Runnable Jar.
In Eclipse:
- Right click on your project
- Export
- Export...
- Runnable JAR file
就像在其他回复中提到的那样,您需要创建一个jar
文件,将所有已编译的类打包。从 Eclipse 导出时,您可以选择导出项目需要运行的依赖项。
如果你想创建一个exe
文件,你可以使用一些软件巫婆包/包装jar(s)
成一个可执行文件。您可以尝试jsmooth,它提供了几个 exe 包装器,并且能够将您的 jar 及其依赖项集成到一个文件中,您可以分发并每次点击执行。
You would have to use chmod in the command line. This argument can change the permission of the file. It depends on three groups. Reading, writing, and executing can all be altered using this argument.
If you want an IDE agnostic solution, go for launch4j