How can I create a Windows .exe (standalone executable) using Java/Eclipse?

后端 未结 3 1362
一向
一向 2020-12-08 11:13

I\'m new to the programming scene. Been working with C++ for about 5 months now, and have decided I want to start getting into Java. I\'m using Eclipse as my IDE, and obvi

相关标签:
3条回答
  • 2020-12-08 11:19

    Creating .exe distributions isn't typical for Java. While such wrappers do exist, the normal mode of operation is to create a .jar file.

    To create a .jar file from a Java project in Eclipse, use file->export->java->Jar file. This will create an archive with all your classes.

    On the command prompt, use invocation like the following:

    java -cp myapp.jar foo.bar.MyMainClass

    0 讨论(0)
  • 2020-12-08 11:37

    Typical Java programs compile into .jar files, which can be executed like .exe files provided the target machine has Java installed and that Java is in its PATH. From Eclipse you use the Export menu item from the File menu.

    0 讨论(0)
  • 2020-12-08 11:41

    Java doesn't natively allow building of an exe, that would defeat its purpose of being cross-platform.

    AFAIK, these are your options:

    1. Make a runnable JAR. If the system supports it and is configured appropriately, in a GUI, double clicking the JAR will launch the app. Another option would be to write a launcher shell script/batch file which will start your JAR with the appropriate parameters

    2. There also executable wrappers - see How can I convert my Java program to an .exe file?

    See also: Convert Java to EXE: Why, When, When Not and How

    0 讨论(0)
提交回复
热议问题