We help IT Professionals succeed at work.

Creating Jar file to run Java application

zolf
zolf asked
on
56 Views
Last Modified: 2016-03-26
Hello there,

I have created a simple Java application and I want to proovide it to the client as Jar file. My software has a 3rd party licence which needs to be there for the application to run. I am using eclipse to bundle the applciation but when i run the application I get error saying cannot find the lic. from eclipse i have place the lic like so

static String licFilePath = "\\lib\\BarCode.lic";

and it is working fine from my eclipse. But when I run it from cmd prompt like so Z:\>java -jar demo.jar

Z:\>java -jar demo.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/se/barcode/License
        at com.demo.Demo2.setLicense(Demo2.java:85)
        at com.demo.Demo2.main(Demo2.java:26)
Caused by: java.lang.ClassNotFoundException: com.se.barcode.License
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 2 more

Open in new window


my MANIFEST file looks like so

Manifest-Version: 1.0
Class-Path: se-barcode-7.6.0.jar se.BarCode.lic
Main-Class: com.demo.Demo2

Open in new window


can somebody please help me resolve this issue.

cheers
Zulf
Comment
Watch Question

Moussa MokhtariEnterpreneur
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
I am using eclipse to bundle the applciation
How - into one jar?

Author

Commented:
CEHJ,

please see screenshot

1

Author

Commented:
Moussa,

l changed my Manifest file as you mentioned but still it cannot find the lic file.
CERTIFIED EXPERT
Top Expert 2016

Commented:
You need to make sure your export options have included dependent libraries/jars
Moussa MokhtariEnterpreneur
Top Expert 2016

Commented:
Try to define in the dependencies from command line like so

java -cp .;lib\*; -jar demo.jar
CERTIFIED EXPERT
Top Expert 2016

Commented:
Try to define in the dependencies from command line like so
This is why it's important to be certain of your goal: is it to use one jar only?

Author

Commented:
thanks for the comments.
How can I use one jar only??
CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks
CERTIFIED EXPERT
Top Expert 2016

Commented:
:)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.