• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError at runtime with 3rd party package  RSS feed

 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to understand the cause and the fix for the code in the imported class in this test program crashing with java.lang.NoClassDefFoundError.

I've written a little test program to exercise this Porter stemmer package: http://ir.dcs.gla.ac.uk/resources/linguistic_utils/porter.java


I took the porter.java file from the Web, saved it as Porter.java, put it into an IRUtilities directory, compiled it, created a jar file from the directory, referenced the package with an import statement, added the path to the jar file to my CLASSPATH file and compiled my test program. There were no errors in the compile. But, when I run my code it catches an exception:


This is line 164, where Porter.java crashes:

The NewString class and constructor method (if I have my terminology right) are near the top of the package file:

Why doesn't the code find the NewString class?

Thanks very much.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did a NewString.class file get created when you compiled Porter.java ? If so, does the jar file you created have NewString.class in it ?
 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did a NewString.class file get created when you compiled Porter.java ? If so, does the jar file you created have NewString.class in it ?


No, just Porter.class. Here's what's in the jar file.



Is there some compiler option I need to give to produce NewString.class?

Thanks.
 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like this was pilot error. When I compiled Porter.java last night it did create NewString.class along with Porter.class. When I built the jar file I must have been tired because I didn't move NewString.java into the directory I built the jar file out of.

Yes, this is a really good argument to use an IDE, or ant or maven, to build jar files.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stan Lederer wrote:Yes, this is a really good argument to use an IDE, or ant or maven, to build jar files.

Or you could just not bother with the jar file at all and just include the IRUtilities directory's parent directory in your classpath.
 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joanne Neal wrote:
Or you could just not bother with the jar file at all and just include the IRUtilities directory's parent directory in your classpath.

Ah, I didn't realize that jar files were optional. Thanks for the education!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!