chaitu
chaitu

Reputation: 1206

How to make jar file created by netbeans work from any location in the system

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.

Upvotes: 0

Views: 2539

Answers (4)

trashgod
trashgod

Reputation: 205785

Complete instructions may be found in dist/README.TXT:

To distribute this project, zip up the dist folder (including the lib folder) and distribute the ZIP file.

Upvotes: 2

Vijay
Vijay

Reputation: 573

Check if in your projects Manifest.mf file has the Attribute "Main-Class" set to your projects current main Class file.

Upvotes: 0

MadProgrammer
MadProgrammer

Reputation: 347234

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

Upvotes: 1

xshoppyx
xshoppyx

Reputation: 1474

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

Upvotes: 1

Related Questions