JAR file runtime error caused by CLASSPATH

P

PhilBray

Hello,

I am having an absolute nightmare trying to get a JAR file that I built
within Eclipse to run via a double click windows environment. I know
that the problem relates back to my CLASSPATH but I am having no luck
at all resolving the issue.

I have about 15 external JAR files that I need to reference from my JAR
and therefore I need to setup a CLASSPATH that will point to all the
external JAR's. I have tried building a manifest file by hand and I
have tried all the CLASSPATH configuration settings that I can find.
Everytime I keep getting a java.lang.NoClassDefFoundError after running
the following command:

java -jar myjarfile.jar

The NoClassDefFoundError relates to a class that exists within one of
my external JAR files. When I use Eclipse to create the JAR it does not
seem to add any 'Class-Path' attribute to it and when I add it myself
Eclipse complains about invalid header sections e.g.

Manifest-Version: 1.0
Class-Path: lib\external_jar_one.jar
Main-Class: com.myapp.mainclass

Does anybody have an easy step by step approach that I can follow that
will get me where I want to be? I will be forever greatful.

Many thanks in advance,

Phil
 
H

hiwa

PhilBray said:
Hello,

I am having an absolute nightmare trying to get a JAR file that I built
within Eclipse to run via a double click windows environment. I know
that the problem relates back to my CLASSPATH but I am having no luck
at all resolving the issue.

I have about 15 external JAR files that I need to reference from my JAR
and therefore I need to setup a CLASSPATH that will point to all the
external JAR's. I have tried building a manifest file by hand and I
have tried all the CLASSPATH configuration settings that I can find.
Everytime I keep getting a java.lang.NoClassDefFoundError after running
the following command:

java -jar myjarfile.jar

The NoClassDefFoundError relates to a class that exists within one of
my external JAR files. When I use Eclipse to create the JAR it does not
seem to add any 'Class-Path' attribute to it and when I add it myself
Eclipse complains about invalid header sections e.g.

Manifest-Version: 1.0
Class-Path: lib\external_jar_one.jar
Main-Class: com.myapp.mainclass

Does anybody have an easy step by step approach that I can follow that
will get me where I want to be? I will be forever greatful.

Many thanks in advance,

Phil
If your current directory is PhilB

C:\PhilB> java -jar myjarfile.jar

Then your myjarfile.jar internal structure should be:

comp\myapp\mainclass.class
---and other classes honoring original package structures as above.

And your external_jar_one.jar should be stored as:

C:\PhilB\lib\external_jar_one.jar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top