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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Assignment 1a" Watch "Assignment 1a" New topic

Assignment 1a

Debbie Christian

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 and class Hundred1a you would get an error like that.
Case matter also, so make sure you run it in the proper case.
Debbie Christian

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 and that you declared your class as Hundred; change into the directory where you've saved your .java file and just type:
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

Joined: Jul 22, 2000
Posts: 9058
Your path must include the /jdk1.3/bin subdirectory to compile.
Your classpath must include the subdirectory where the *.java (in this case 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 file? Is that subdirectory in your classpath?
[ October 23, 2003: Message edited by: Marilyn de Queiroz ]

"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

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:
subject: Assignment 1a
jQuery in Action, 3rd edition