This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Code not working

 
Ranch Hand
Posts: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...


 
lowercase baba
Posts: 13081
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic