Current location: Hot Scripts Forums » Programming Languages » Everything Java » New to Java: weird main error msg


New to Java: weird main error msg

Reply
  #1 (permalink)  
Old 02-08-04, 04:41 PM
hecresper hecresper is offline
New Member
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
New to Java: weird main error msg

Hi,

I just got the book Teach Yourself Java 2 Platfrom in 21 days, Professional Reference Edition. I typed in and compiled the following code in Notepad:

code:class Jabberwock {
String color;
String sex;
boolean hungry;

void feedJabberwock() {
if (hungry == true) {
System.out.println("Yum -- a peasant!");
hungry = false;
} else
System.out.println("No, thanks -- already ate.");
}

void showAttributes() {
System.out.println("This is a " + sex + " " + color + " jabberwock.");
if (hungry == true)
System.out.println("The jabberwock is hungry.");
else
System.out.println("The jabberwock is full.");
}

public static void main (String arguments[]) {
Jabberwock j = new Jabberwock();
j.color = "orange";
j.sex = "male";
j.hungry = true;
System.out.println("Calling showAttributes ...");
j.showAttributes();
System.out.println("-----");
System.out.println("Feeding the jabberwock ...");
j.feedJabberwock();
System.out.println("-----");
System.out.println("Calling showAttributes ...");
j.showAttributes();
System.out.println("-----");
System.out.println("Feeding the jabberwock ...");
j.feedJabberwock();
}
}



It seems straightforward enough. Except that I get the following error message after typing java Jabberwock:

Exception in thread "main" java.lang.NoClassDefFoundError: Jabberwock

The code compiles without an error message with javac Jabberwock.java

Any ideas as to what's causing the message to appear?

Also, the program compiles and runs fine within JPad. I get no error message in the Interactive window. I only get the error message when I'm in the DOS command prompt.

Thanks.

P.S.
I've checked the books web site and it does not mention that the error should turn up. Much less how to fix it.
Reply With Quote
  #2 (permalink)  
Old 02-08-04, 06:08 PM
stdunbar stdunbar is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Superior, CO, USA
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Try to run "java -classpath . Jabberwock". That is a dot for the classpath and spaces between each of the arguments. Depending on the Java runtime environment you are using you may have to specify that. This assumes that you are running the java command from the directory that contains Jabberwock.class.


Quote:
Originally Posted by hecresper
Exception in thread "main" java.lang.NoClassDefFoundError: Jabberwock
Reply With Quote
  #3 (permalink)  
Old 02-10-04, 03:03 PM
esh esh is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Roswell, GA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
here is a very simple IDE if you want to try it out.

http://www.jgrasp.org/

free of course.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript menu covered by java applet shaisachs JavaScript 7 12-28-04 11:38 PM
We need more java talk rooshine Everything Java 4 05-08-04 10:44 PM
java source code veena vahini Everything Java 1 01-29-04 10:25 AM
one main method sniperx Everything Java 6 01-23-04 06:02 AM
Java forum name "everything java" esh Everything Java 0 10-13-03 09:05 AM


All times are GMT -5. The time now is 05:57 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.