Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Exception in thread "main" java.lang.NoClassDefFoundError

Exception in thread "main" java.lang.NoClassDefFoundError
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Jan 31, 2003, 05:46 PM
 
java error in mac os x.2.3 terminal.

I get this error "Exception in thread "main" java.lang.NoClassDefFoundError" when I try to run my *.class file under Terminal? What should I do?

I think I compile it correctly cause it pop up a *.class file with no error comment


i have a screenshot of the error @ <a href="http://www.sfu.ca/~jchungd/javaerror.jpg" </a>
     
pnz999  (op)
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Jan 31, 2003, 05:46 PM
 
the source code "import javax.swing.JOptionPane;

public class circle
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog ("Please enter the radius");
double rad = Double.parseDouble(input);

double area = Math.PI*2*rad;
double cir = Math.PI*Math.pow(rad,2);

System.out.println("The area is " + area + ".");
System.out.println("The circumference is " + cir + ".");
}
}
"
     
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Jan 31, 2003, 06:30 PM
 
You need to be in /Users/palm/Desktop/ because that's where circle.class is
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 31, 2003, 06:43 PM
 
Or you can use java -cp /Users/jung/Desktop circle.
     
pnz999  (op)
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Feb 1, 2003, 12:12 PM
 
It work! Thanks

I just need to be in the same directory as my *.java and *.class files.


BTW, is it possible to do C++ programming in a mac? can i still use Terminal? because in second year university we will be learning C, C++, and Java



and also How can I tell what version of Java in on my machine(10.2.3 / G4 MDD)? and Java on a Mac is the same as Sun's Java?

cause current Sun's Java version is 1.4.1_01


---------------------------
What programming language does Mac OS X or any Mac app (photoshop) use?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 1, 2003, 05:12 PM
 
Originally posted by pnz999:
BTW, is it possible to do C++ programming in a mac? can i still use Terminal? because in second year university we will be learning C, C++, and Java
Sure you can do C++ programming on the Mac. It uses the standard GNU tools, which include a C++ compiler. And yes, you can still use the Terminal. Though honestly it eludes me why you wouldn't want to use Project Builder's specialized interface.

and also How can I tell what version of Java in on my machine(10.2.3 / G4 MDD)? and Java on a Mac is the same as Sun's Java?

cause current Sun's Java version is 1.4.1_01
Type java -version to see the version of Java installed on your system. But I can already tell you it will be 1.3.1. Apple has had 1.4.1 in development for quite a while now. I don't expect it will be too much longer before they bring that out...but people have been saying that for months.

What programming language does Mac OS X or any Mac app (photoshop) use?
Whatever programming language the author feels like using. Photoshop, to my knowledge, is C++. OmniWeb is Objective-C. IOKit drivers are written in pure C. Limewire is Java. And many apps nobody seems to like are written in REALbasic.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
pnz999  (op)
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Feb 1, 2003, 08:33 PM
 
"And many apps nobody seems to like are written in REALbasic."

Whats wrong with REALbasic?


Project Builder, eh? My teacher recommend Codewarrior, it support both windows and mac, but its pretty expensive. Are all IDEs pretty much the same or not?

Project Builder is free and the lastest rev. is the Dec. 2002 version 2.1 right?

Does Project builder comes bundles with compiler that compiles C, C++, obj-C, obj-C++, perl, java? or is it a seperate download for compilers?
(Last edited by pnz999; Feb 1, 2003 at 09:00 PM. )
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 1, 2003, 09:11 PM
 
PERL comes with OS X. All of the others you listed come w/ the developer tools. I wouldn't place too much faith in what that teacher has to say. Project Builder uses the gcc which has been ported to FAR more platforms than Codewarrior. You can get a Windows port of the gcc at http://www.cygwin.com
     
Mac Elite
Join Date: May 2001
Location: ~/
Status: Offline
Reply With Quote
Feb 2, 2003, 12:42 PM
 
GCC may have been ported to more systems than Codewarrior but CW is a full IDE, GCC is just a compiler. Project Builder is ok for a free IDE but is really unlike many other IDEs you will run across programming on different platforms. Learning a language is great but you also need to learn to use the tools available, learning PB instead of CW is going to put you at a disadvantage anywhere that uses an IDE more similar to CW/VC++/Krylix.
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 3, 2003, 02:45 AM
 
Care to give an example as to what makes Project Builder so different than the IDEs you mentioned?

Project Builder and the IDEs you listed all offer an editor, a view of files in your project, a class hierarchy view, integrated help, and handle the compile and link phases for you.

The only features I can think of that Project Builder lacks are Intellisense(TM) and a bunch of goofy wizards. How exactly does not being familiar with these two features put you at a great disadvantage? How does knowing how to setup compile and link options in CodeWarrior help you when confronted with Visual Studio or Delphi/Kylix? Did the IDE vendors all submit to some standard that Apple missed out on?

CodeWarrior for Windows is a joke. If you're a professional software house that writes C/C++ code for Windows, you use Visual Studio. I believe it's actually carved in stone somewhere.

If you want to see an IDE "really unlike many other IDEs you will run across" check out IBM's VisualAge for Java or VisualAge for Smalltalk.
     
Junior Member
Join Date: Sep 2000
Status: Offline
Reply With Quote
Feb 3, 2003, 08:10 AM
 
Thought I'd just give you my two peneth on your Java code :-)

Originally posted by pnz999:
the source code "import javax.swing.JOptionPane;

public class circle
You should give your class names a capital letter at the start, and make sure the .java file matches.
Nobody made a greater mistake than
he who did nothing because he could only
do a little. Edmund Burke
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2