?
Solved

java.lang.NoClassDefFoundError error!

Posted on 2004-08-26
14
Medium Priority
?
251 Views
Last Modified: 2010-03-31
Hi all,

I'm trying to run my own .jar file, it refers classes collected in another jar file. Both of this ".jar" files are in same directory. When all of this classes were under developing everything was ok, but now, when I separated this classes in different jars, there is something wrong! I really don't know what is it!!!!!!!!!!!!!
I'm trying with this line : "java -jar my.jar someparameters"
My classpath also seems ok, I added "." at the begining of my classpath as well, but I'm still getting this error : Exception in thread "main" java.lang.NoClassDefFoundError: sss/com/DocListener.
Any suggestions?
Thanks in advance!
0
Comment
Question by:Valeri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11900768
Try:

java -classpath <your other jar file> -ja my.jar <some parameters>
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11900773
try:
java -classpath putHereTheOtherjarFile -jar my.jar someparameters
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11900777
about same time
:)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Author Comment

by:Valeri
ID: 11900934
It also does not works! I tried it as well, but I forgot to mention this in my question. When all of this classes are in same jar they work fine, but now they don't work. It seems like problem of class loader or something else?!?!
I don't know!
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11900945
> sss/com/DocListener
the noclassdeffounderror, is in A.jar or in B.jar ???

java -classpath A.jar -jar B.jar <someparameters>
0
 
LVL 35

Expert Comment

by:girionis
ID: 11900953
Does you jar have the file DocListener?

What happens if you do (assumin *nix):

jar -tfv <your jar> | grep DocListener
0
 
LVL 16

Author Comment

by:Valeri
ID: 11901291
The DocListener class is in jar A. Yes, the jar A contains DocListener class, I checked this...
0
 
LVL 35

Expert Comment

by:girionis
ID: 11901548
Can you tell me where *exactly* the A.jar file is, the B.jar file is, what is your current working directory and the command you are using to run them?
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11901732
If you open the A.jar do you find DocListener.class in sss/com/ directory?
0
 
LVL 16

Author Comment

by:Valeri
ID: 11903091
Yes, my class exists in A.jar.
I'm using this command :  "java -classpath A.jar -jar B.jar someparameters" . The class with main method is in B.jar and java is looking for the class in A.jar. The error that I'm getting is : Exception in thread "main" java.lang.NoClassDefFoundError: sss/com/DocListener. Both of the jar files are in the project directory!
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11903125
Ok, but if you open the A.jar do you find DocListener.class in the directory

sss/com/

?
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 11907326
Add a Class-Path attribute to your manifest to reference the other jar

eg.

Class-Path: A.jar

Then run it with:

java -jar B.jar
0
 
LVL 16

Author Comment

by:Valeri
ID: 11910308
Yeah! :-))))))))))))))))))))))))))))))))))))
"objects" is always the right person! Many, many, many thanks objects! ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 11918775
glad we could help resolve your problem :)

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question