• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError

 
Tony Maro
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at all the other posts re this topic but still don't have an answer. And this is too simple to be in anything other than beginner.

My application is not finding a class file enclosed in a jar file. Specifically, I use com.ibm.as400.access.as400.class from jt400.jar (which is in my classpath. I'm not familiar enough with this type of directory structure (com.ibm.as400.access) to solve this problem. But I think the issue is with the classpath.

The specific error looks like this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/as400/access/as400 at .....

Your help is appreciated.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by tony maro:
...My application is not finding a class file enclosed in a jar file. Specifically, I use com.ibm.as400.access.as400.class from jt400.jar (which is in my classpath...

Welcome to JavaRanch!

How exactly is this specified in your classpath? If the class is in a jar, then it's not enough to specify just the directory that contains the jar -- you need to include the jar itself in the classpath. That is, all the way through (including) "...jt400.jar".
[ May 18, 2006: Message edited by: marc weber ]
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by tony maro:
I looked at all the other posts re this topic but still don't have an answer. And this is too simple to be in anything other than beginner.

My application is not finding a class file enclosed in a jar file. Specifically, I use com.ibm.as400.access.as400.class from jt400.jar (which is in my classpath. I'm not familiar enough with this type of directory structure (com.ibm.as400.access) to solve this problem. But I think the issue is with the classpath.

The specific error looks like this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/as400/access/as400 at .....

Your help is appreciated.



Great, to see the problem again.

There are 3 possiblities.

1) you might not have included the jar file in the classpath. first verify whether you have included the jar file in the path. then try to run it.

if still you get the problem then proceed to step 2.

2) another problem is the access rights of the jar file. please verify whether you have read and execute rights for that particular jar file. if not then modify the access permissions then try to run it.

if still you get the problem then procees to step 3.

3) check the java policy file of that particular jar file. whether it is compitable to your java version or not.

if still you get the problem the post the java file to ranch surface.

Thank you.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the API documentation. The class name is "AS400" with uppercase letters.
 
Tony Maro
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all (3) for your responses. Here's more details I'm using a .bat file to execute this. MyJar.jar is located in "subdirectory". Obviously some names changed to protect the innocent. My .bat looks something like this.

cd \program files\java\subdirectory
java -cp .;c:\prog~01\java\jt400.jar -jar MyJar.jar

DOS execution window follows;

C:\>cd \program files\java\subdirectory

C:\Program Files\Java\subdirectory>java -cp c:\prog~01\java\jt400.ja
r -jar MyJar.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/as400/access/
AS400
at subdirectory(MyJar.java:86)
at subdirectory.MyJar.main(MyJar.java:70)

The issue seems to be that the class AS400 is embedded in the directory structure "com.ibm.as400.access" within the jar file. Regarding the reply to check access rights and stuff, I don't know how to do that.
 
Ramen Chatterjee
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

The folder structure in the jar is correct, as it reflects the package structure of the class. So if I created a jar with a class called com.myapp.KillerApp.class, the KillerApp class would have to be in a folder called myapp, which was in a folder called com.

Ramen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic