Export JAR with Netbeans

后端 未结 4 1879
旧时难觅i
旧时难觅i 2020-11-28 08:58

How to export java project to JAR with Netbeans ? I cannot find options like in Eclipse.

相关标签:
4条回答
  • 2020-11-28 09:05

    You need to enable the option

    Project Properties -> Build -> Packaging -> Build JAR after compiling

    (but this is enabled by default)

    0 讨论(0)
  • 2020-11-28 09:08
    1. Right click your project folder.
    2. Select Properties.
    3. Expand Build option.
    4. Select Packaging.
    5. Now Clean and Build your project (Shift +F11).
    6. jar file will be created at your_project_folder\dist folder.
    0 讨论(0)
  • 2020-11-28 09:13

    It does this by default, you just need to look into the project's /dist folder.

    0 讨论(0)
  • 2020-11-28 09:24

    Do you mean compile it to JAR? NetBeans does that automatically, just do "clean and build" and look in the "dist" subdirectory of your project. There will be the JAR with "lib" folder containing the required libraries. These JAR + lib are enough to run the application.

    If you disable "Compile on save" in the project properties, then it is no longer necessary to do "clean and build", simply "build" will suffice in most cases. This will save time if you want to change just a bit of the code and rebuild the JAR. However, note that NetBeans sometimes fails to handle dependencies and binary compatibility properly, which will lead to a faulty JAR throwing "no such method" or other obscure exceptions. Therefore, if you made a lot of changes since the last full rebuild and even remotely unsure that it will still work even if some classes aren't recompiled, then you must still do a full "clean and build" in order to get a perfectly working JAR.

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