Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Code not working  RSS feed

 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings everyone, I'm currently on chapter 2. in the so far excellent book of "Head First Java". I just went ahead and created the following:



As I test on what I have gone over thus far in chapter two (it's clearly based on the Dog example given in Chapter 2). However, I'm getting this error from the compiler:

lamoubeldum@LamouBeldum:~/JavaPrograms/Exercises$ java CatTester.java
Error: Could not find or load main class CatTester.java

I don't believe I'm doing anything wrong, but you never know. Thanks!
 
Stefan Evans
Bartender
Posts: 1836
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Welcome to the ranch.

Yeah, "java CatTester.java" is the wrong thing to be running.
If you want to compile this, the correct command is "javac" not "java"
javac is the compiler that turns your java source code into a class file.
You would then execute java on the compiled class file.

The instructions should be:




cheers,
Stefan

P.S: note there is currently an error in your CatTester class that compiling with javac should highlight for you
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:. . . (note there is currently an error in your CatTester class that compiling with javac should highlight for you)

cheers,
Stefan



Oh gosh, how could I make such a careless error. Most ridiculous error to make ROFLL. Thanks!
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:. . . note there is currently an error in your CatTester class that compiling with javac should highlight for you


fixed the compiled error too btw, can't believe I typed "New" instead of "new". I need to pay more attention and be extra careful. Thank you so much!
 
Stefan Evans
Bartender
Posts: 1836
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats it exactly :-)

Oh, and get used to this feeling of "doh, I can't believe I made such a stupid mistake"
It's part and parcel of programming. I particularly hate it when I've been tearing my hair out over a bug for an hour, and someone points out the obvious mistake after a two second glance over my shoulder...


 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naziru Gelajo wrote:Oh gosh, how could I make such a careless error. Most ridiculous error to make...

and yet, it's probably one we see weekly here. EVERYONE has done this. An you will make about a billion more errors like this if you keep programming. But this is the pain that then makes the elation with it works so much more rewarding.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!