• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple java program fails  RSS feed

 
Nathalie Vaiser
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm following the book 'Orielly Headfirst start Java 2nd edition" and the very first java app is failing for me. This is all it is:




it compiled with no errors, but when I try to run it:


c:\Dropbox\programming\java\headfirst>java MyFirstApp.class
Error: Could not find or load main class MyFirstApp.class


I'm using the latest Java JDK (jdk1.7.0_25)


As far as I can tell I typed the code exactly like in the book. Any ideas?

Thanks
 
Brian Storenson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code worked for me. What IDE are you using? Did you remember to save the file before running it? In Eclipse, there will be an asterisk by the MyFirstApp.java tab if there has been changes and you haven't saved it. Did you install the JDK?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No IDE obviously, as the java command is being run from the command line.

Do not specify ".class" on the command line -- just the name of the class.
 
Brian Storenson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
type java MyFirstApp at the command line.
 
Nathalie Vaiser
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, that did the trick (just typing the file name and not .class with it)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!