File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assignment 1a

 
Debbie Christian
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1070
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Brad Ford
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, are you on Windows or Linux or other? That may help with figuring out what's wrong.
 
Debbie Christian
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic