aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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: 42273
    
  64
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Run class file using Terminal on Mac Leopard