aspose file tools*
The moose likes Beginning Java and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

Tony Maro
Greenhorn

Joined: Jan 24, 2006
Posts: 2
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

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

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

Joined: Aug 31, 2004
Posts: 11343

I found the API documentation. The class name is "AS400" with uppercase letters.
Tony Maro
Greenhorn

Joined: Jan 24, 2006
Posts: 2
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

Joined: Apr 27, 2006
Posts: 62
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


Could try harder
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError