Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

executing jar : NoClassDefError

Thread view: 
Leena - 18 Jul 2006 21:31 GMT
Hi,

I have made a jar file and I'm trying to execute the jar file, but it
gives me NoClassDefError. However, when I extract the jar file, I see
that class but, jar file in not able to find it.

The only different thing I'm doing is I've extracted another jar file
and added the content of that jar file in my jar. Since my project
needs to refer to another jar file, I had to extract the content of
that jar file and put it in my jar. This was suggested in previous
discussion.

Any suggestions, why jar is not able to find a class which I can see in
the jar?

Thanks,
Leena
Andrew Thompson - 18 Jul 2006 23:03 GMT
..
> I have made a jar file and I'm trying to execute the jar file, but it
> gives me NoClassDefError.
....
> The only different thing I'm doing is I've extracted another jar file
> and added the content of that jar file in my jar. ....

Other jars can be added to the classpath at runtime.
It is neither necessary, nor recommended, to 'rejar'
all resources into a single jar.

> Any suggestions, why jar is not able to find a class which I can see in
> the jar?

That probably depends a lot on the exact contents of the jar,
and the manifest file, neither of which we can see from here.
Why don't you upload the jar (how big is it?) to a free site and
let us have a look at it?

Andrew T.
Leena - 18 Jul 2006 23:16 GMT
Hi Andrew,

I found the problem!

I was wrongly creating the jar file. Even though my jar file had all
the class file, I was creating a folder and was storing classes of the
"available" jar file in that folder. So at runtime, since the classes
were inside folder(the one that I created) one level down, jar could
not find classes and throw error.

Less learnt: If the jar file is not working, then extract the jar file
and check the folder structure. This might give you the clue.

Thanks Andrew for your time,

Leena

> ..
> > I have made a jar file and I'm trying to execute the jar file, but it
[quoted text clipped - 16 lines]
>
> Andrew T.
Andrew Thompson - 18 Jul 2006 23:38 GMT
> I found the problem!

Yay!  Thanks for reporting the solution.

<snip>
> Thanks Andrew for your time,

You're welcome.

Andrew T.
Nigel Wade - 19 Jul 2006 14:18 GMT
> ..
>> I have made a jar file and I'm trying to execute the jar file, but it
[quoted text clipped - 4 lines]
>
> Other jars can be added to the classpath at runtime.

If it's a jar which is being executed via the -jar command line argument then
the classpath comes from the manifest of the specified jar, and can't be
modified at runtime. In this case the external jar needs to be added to the
classpath in the executable jar's manifest when it is built.

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Carlus Henry - 20 Jul 2006 03:26 GMT
>> ..
>>> I have made a jar file and I'm trying to execute the jar file, but it
[quoted text clipped - 8 lines]
> modified at runtime. In this case the external jar needs to be added to the
> classpath in the executable jar's manifest when it is built.

I had a similar situation that may or may not help.  I was building
entries in the MANIFEST.MF file through my ant build script.  Well, what
I made a mistake and did was put a ":" at the end of my Built-By or some
other key value like that.  It completely rendered my jar inoperable.  I
got all kind of wacky strange errors.

Make sure that the MANIFEST.MF file is not breaking spec in some sort of
way.

Thanks
Carlus
sayom88@gmail.com - 19 Jul 2006 17:05 GMT
> Hi,
>
[quoted text clipped - 13 lines]
> Thanks,
> Leena
sayom88@gmail.com - 19 Jul 2006 17:07 GMT
i have the solution


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.