Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

Creating Jar file to run Java application

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
SOLUTION
Avatar of Moussa Mokhtari
Moussa Mokhtari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CEHJ
I am using eclipse to bundle the applciation
How - into one jar?
Avatar of Zolf

ASKER

CEHJ,

please see screenshot

User generated image
Avatar of Zolf

ASKER

Moussa,

l changed my Manifest file as you mentioned but still it cannot find the lic file.
You need to make sure your export options have included dependent libraries/jars
Avatar of Moussa Mokhtari
Moussa Mokhtari

Try to define in the dependencies from command line like so

java -cp .;lib\*; -jar demo.jar
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?
Avatar of Zolf

ASKER

thanks for the comments.
How can I use one jar only??
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zolf

ASKER

Thanks
:)