I have a java desktop application in netbeans. I have created an executable jar file for the project using clean and build command provided by the netbeans. By using this command the executable jar file gets created under netbeansProjects//dist/.jar. I am able to execute this jar file from command line using java -jar .jar from within project path. But the problem is that when i move this jar outside of netbeans projects folder, say to desktop and run the jar file, it is giving error of type "Exception in thread "main" java.lang.NoClassDefFoundError". How to solve this problem and make the jar file executable from any location of the system.
How to make jar file created by netbeans work from any location in the system
2.5k Views Asked by chaitu At
4
There are 4 best solutions below
2
On
Netbeans has probably included any external projects/libraries/Jars in the dist/lib folder.
In order to run the application, you must include all the files in the dist folder when you copy the application
Ensure that the manifest inside of the jar file contains the necessary classpaths. If you are unfamiliar with the concept, go here: http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html