wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Run class file using Terminal on Mac Leopard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Run class file using Terminal on Mac Leopard" Watch "Run class file using Terminal on Mac Leopard" New topic
Author

Run class file using Terminal on Mac Leopard

Toca Car
Greenhorn

Joined: Nov 03, 2008
Posts: 4
I am a total beginner with Java, currently working my way through the Head First Java 2nd Edtn book. I have made a DotComBust game (as part of the book) which compiles and runs fine on my PC. But when I try to run the class file using Terminal on my Mac (Leopard 10.5.5), I get the following error msg:

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

I have tried re-compiling the java file using Terminal on my Mac and it does this fine. It just won't run the class file! I was advised to start using something other than Terminal/ TextEdit to work with Java (BlueJ) as this would be easier (the class file runs fine in BlueJ), but the Head First book wants me to learn with TextEdit and Terminal. If anyone can advise me what to do, I would be most grateful.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Try this:

Then it should find any classes within the current directory. (It's possible that the CLASSPATH environment variable is set, which complicates things. It's better to do without it, specifying the classpath as part of the "java" command.)


Ping & DNS - my free Android networking tools app
 
wood burning stoves
 
subject: Run class file using Terminal on Mac Leopard