This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Cattle Drive and the fly likes Assignment 1a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Assignment 1a" Watch "Assignment 1a" New topic
Author

Assignment 1a

Debbie Christian
Greenhorn

Joined: Mar 26, 2001
Posts: 8
I've written my program and compiled it with no errors. When I run it i get the following
Exception in thread "main" java.lang.NoClassDefFoundError: Hundred
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Your class name has to be the name of the file you save it as. So if you have file Hundred.java and class Hundred1a you would get an error like that.
Case matter also, so make sure you run it in the proper case.
Bill
Debbie Christian
Greenhorn

Joined: Mar 26, 2001
Posts: 8
I've sortof figured out my problem - I must compile and execute my programs in the /jdk1.3/bin subdirectory. I thought I didn't have to as long as I have that /jdk1.3/bin in my classpath and I use the -sourcepath and -d flags of the javac command. That didn't work for me tho. Any comments?
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Debbie,
You don't have to put your files in the jdk1.2\bin directory.
If you're sure your file is named Hundred.java and that you declared your class as Hundred; change into the directory where you've saved your .java file and just type:
javac Hundred.java
Don't set classpath or use any other flags. jdk1.3 will find everything ok as long as your PATH is set to include the jdk1.3\bin directory (this should have happened as a normal part of the install).
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Your path must include the /jdk1.3/bin subdirectory to compile.
Your classpath must include the subdirectory where the *.java (in this case Hundred.java) is stored to be able to run the programs. I store all my *.java (java code files) in ~/java and my classpath is set to ".;~/java".
After you've compiled your program (without using -d or -sourcepath), can you see the Hundred.class file in the same subdirectory as the Hundred.java file? Is that subdirectory in your classpath?
[ October 23, 2003: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Brad Ford
Ranch Hand

Joined: Mar 22, 2001
Posts: 40
Also, are you on Windows or Linux or other? That may help with figuring out what's wrong.
Debbie Christian
Greenhorn

Joined: Mar 26, 2001
Posts: 8
Thanks guys!! . The problem was I didn't have the subdirectory containing my source file in my classpath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assignment 1a
 
Similar Threads
Cant use object from another class
WA #1.....word association
Posting to bump up my count...
Text box value is not being completely filled with request attribute
The x900 effect ?