Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » NoClassDefFoundError
NoClassDefFoundError [message #169278] Mon, 04 September 2006 16:05 Go to next message
Eclipse UserFriend
Originally posted by: public.room32.net

I am working with Bruce Eckel's Thinking In Java 4

I have created a project and added his net.mindview.util library (a class
folder) containing a print method to the Build Path ( Java Build Path >
Libraries > Add Class Folder > Create New Folder... > Advanced)

I assumed it worked since eclipse will compile the following program with
no errors:

package myPackage;
import static net.mindview.util.Print.*;

public class Test{

public static void main(String[] args) {
print("abcdefg");
}
}

but there is a runtime error:

Exception in thread "main" java.lang.NoClassDefFoundError:
myExtLIb/net/mindview/util/Print
at myPackage.Test.main(Test.java:14).

so now JDT cannot find the byte code for print() ? I thought eclipse
already checked for these dependencies.

The Eclipse help describes the process of linking class files:

"In order to still benefit from external .class files, a class folder
must be mounted as a linked folder in Eclipse workspace (in project
properties, select Java Build Path > Libraries > Add Class Folder > Create
New Folder... > Advanced. Then a folder name can be associated with an
arbitrary file system location by checking "Link to folder on the file
system). "

I thought that was it, but then it goes on:

"Once mounted, the linked class folder can normally be referenced on a
build path, and from there on programs can be compiled against it."

do I further have to reference my linked classes? and if so; where/how?

thanks,
john
Re: NoClassDefFoundError [message #169382 is a reply to message #169278] Tue, 05 September 2006 04:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse4.rizzoweb.com

john doe wrote:
> I am working with Bruce Eckel's Thinking In Java 4
>
> I have created a project and added his net.mindview.util library (a
> class folder) containing a print method to the Build Path ( Java Build
> Path > Libraries > Add Class Folder > Create New Folder... > Advanced)

[snip]
>
> but there is a runtime error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> myExtLIb/net/mindview/util/Print
> at myPackage.Test.main(Test.java:14).
>
> so now JDT cannot find the byte code for print() ? I thought eclipse
> already checked for these dependencies.

Remember that the build path is separate from any runtime classpath. You
included the .class files on your project build path, but when you
launch the application the runtime classpath does not include that same
location for some reason.
You need to edit the Launch Configuration to include the .class folder.
The Eclipse Help contains all the details you need about Launch
Configurations.

Hope this helps,
Eric
Re: NoClassDefFoundError [message #169444 is a reply to message #169382] Tue, 05 September 2006 09:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: public.room32.net

thanks for the hint!

I'll have a look at that now (might come back if I get stuck again).
Re: NoClassDefFoundError [message #169468 is a reply to message #169382] Tue, 05 September 2006 10:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: public.room32.net

hm ... although I wasn't aware of the launch configuration before you
mentioned it, it does seem that this automatically have copied the
settings from the projects properties. Certainly the same entries are
present in the classpath tab of the 'Modify Atributes and Launch'-window
for the current class.

do you always set these Launch settings by hand yourself?
Re: NoClassDefFoundError [message #169568 is a reply to message #169468] Tue, 05 September 2006 14:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse4.rizzoweb.com

John Doe wrote:
> hm ... although I wasn't aware of the launch configuration before you
> mentioned it, it does seem that this automatically have copied the
> settings from the projects properties. Certainly the same entries are
> present in the classpath tab of the 'Modify Atributes and Launch'-window
> for the current class.
>
> do you always set these Launch settings by hand yourself?
>

Not always, but sometimes. It is not always the case that the runtime
classpath should be the same as the build path; in those cases, or when
there is extra configuration needed for running an app, I do edit the
Launch Configs by hand.

So are you saying that the .class files appear to be on the launch
classpath but your app is still failing to find them?

Eric
Re: NoClassDefFoundError [message #169878 is a reply to message #169278] Thu, 07 September 2006 03:26 Go to previous message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

john doe wrote:
> I am working with Bruce Eckel's Thinking In Java 4
>
> I have created a project and added his net.mindview.util library (a
> class folder) containing a print method to the Build Path ( Java Build
> Path > Libraries > Add Class Folder > Create New Folder... > Advanced)
>
> I assumed it worked since eclipse will compile the following program
> with no errors:
>
> package myPackage;
> import static net.mindview.util.Print.*;
>
> public class Test{
>
> public static void main(String[] args) {
> print("abcdefg");
> }
> }
>
> but there is a runtime error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> myExtLIb/net/mindview/util/Print
> at myPackage.Test.main(Test.java:14).
>
> so now JDT cannot find the byte code for print() ? I thought eclipse
> already checked for these dependencies.
> The Eclipse help describes the process of linking class files:
>
....snip

Are you sure that you have compiled the class. The error message that
you posted doesn't match up with the source that you posted. The stack
trace indicates that the error occurs at line 14. However, your source
code looks like it only has 9 lines. The package name for the
exceptions also indicates that the missing package is
myExtLib.net.minview.util. Is it possible that you have an old version
of the class somewhere in your project?
Previous Topic:compability problem?
Next Topic:Accessing file in plugin.xml
Goto Forum:
  


Current Time: Fri Apr 26 17:32:41 GMT 2024

Powered by FUDForum. Page generated in 0.08418 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top