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
JavaJava EE

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
SOLUTION
Moussa Mokhtari

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
CEHJ

I am using eclipse to bundle the applciation
How - into one jar?
ASKER
Zolf

CEHJ,

please see screenshot

1
ASKER
Zolf

Moussa,

l changed my Manifest file as you mentioned but still it cannot find the lic file.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
CEHJ

You need to make sure your export options have included dependent libraries/jars
Moussa Mokhtari

Try to define in the dependencies from command line like so

java -cp .;lib\*; -jar demo.jar
CEHJ

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?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Zolf

thanks for the comments.
How can I use one jar only??
ASKER CERTIFIED SOLUTION
CEHJ

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Zolf

Thanks
CEHJ

:)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy