Runtime error in example code - don't know why [message #153874] |
Wed, 24 May 2006 08:05 |
Eclipse User |
|
|
|
Originally posted by: kerry.jcs.co.uk
I have started working my way through "Thinking in Java". In chapter 3 there
is an example translated into Eclipse 3.1 as shown at the end.
The Problems tab show no errors or warnings. But when I run the file as a
Java app I get:
java.lang.NoClassDefFoundError: bruceeckel/simpletest/Test
at assignment.<clinit>(assignment.java:6)
Exception in thread "main"
Is this because I have linked in the supporting files incorrectly?
I created a project "chapter3" and added a class folder in the library of
the project's Java Build Bath (with a link to the folder on the tree).
The element simpletest now appears in the Package Explorer for the
project.The Build Path -> library shows "(None)" against Source, Javadoc
and Native library location. Is this correct?
Thanks
Kerry
//: c03:Assignment.java
import simpletest.Test;
public class assignment {
static Test monitor = new Test();
public static void main(String[] args) {
Number n1 = new Number();
Number n2 = new Number();
n1.i = 9;
n2.i = 47;
System.out.println("1: n1.i: " + n1.i +
", n2.i: " + n2.i);
n1 = n2;
System.out.println("2: n1.i: " + n1.i +
", n2.i: " + n2.i);
n1.i = 27;
System.out.println("3: n1.i: " + n1.i +
", n2.i: " + n2.i);
monitor.expect(new String[] {
"1: n1.i: 9, n2.i: 47",
"2: n1.i: 47, n2.i: 47",
"3: n1.i: 27, n2.i: 27"
});
}
} ///:~
|
|
|
Re: Runtime error in example code - don't know why [message #155709 is a reply to message #153874] |
Tue, 06 June 2006 11:35 |
Eclipse User |
|
|
|
Originally posted by: eclipse4.rizzoweb.com
Kerry Frater wrote:
> I have started working my way through "Thinking in Java". In chapter 3 there
> is an example translated into Eclipse 3.1 as shown at the end.
>
> The Problems tab show no errors or warnings. But when I run the file as a
> Java app I get:
> java.lang.NoClassDefFoundError: bruceeckel/simpletest/Test
>
> at assignment.<clinit>(assignment.java:6)
>
> Exception in thread "main"
>
> Is this because I have linked in the supporting files incorrectly?
> I created a project "chapter3" and added a class folder in the library of
> the project's Java Build Bath (with a link to the folder on the tree).
Thinking In Java is an excellent resource, but I suggest you also go
through the Eclipse tutorials and Getting Started Guides. In Eclipse,
select Help > Help Contents and then go into the Java Dev User Guide,
Getting Started. The info there will help you understand how to set up
various kinds of projects in Eclipse, and then you can resume your TiJ
tutorials (or do them simultaneously with the Eclipse tutorials).
Hope this helps,
Eric
|
|
|
Powered by
FUDForum. Page generated in 0.08401 seconds