GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Can not run a simple program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can not run a simple program" Watch "Can not run a simple program" New topic
Author

Can not run a simple program

Daniel Palmer
Greenhorn

Joined: Nov 30, 2005
Posts: 2
I'm learning Java from the "Head First Java" book. I'm trying to run MyFirstApp which is basically a Hello World type of application. I run Windows XP and I'm jusing Java 5.0. I am able to compile, but when I try to run I get an error:

c:\learn\java>javac MyFirstApp.java

c:\learn\java>java MyFirstApp.class
Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp/class

I've read about setting the CLASSPATH variable, but I have tried that as well and I still can't get it to work. Any help here would be greatly appreciated.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3606
    
  15
Remove the .class part of the command line.
Use just
java MyFirstApp


Joanne
Daniel Palmer
Greenhorn

Joined: Nov 30, 2005
Posts: 2
Thank you very much.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sounds like you got over this hurdle. As you explore compiling and running programs, see if THIS (shameless self promotion) helps.
[ November 30, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
GeeCON Prague 2014
 
subject: Can not run a simple program