Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export JAR with Netbeans

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

like image 237
Damir Avatar asked Dec 21 '10 10:12

Damir


People also ask

How do I export from NetBeans?

You can use Files>Export>Browse to Export in netbeans.

How do I export a runnable jar?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.


2 Answers

You need to enable the option

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

(but this is enabled by default)

like image 84
a_horse_with_no_name Avatar answered Sep 22 '22 11:09

a_horse_with_no_name


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.

like image 39
Sergei Tachenov Avatar answered Sep 21 '22 11:09

Sergei Tachenov