• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Error when attempting to Execute (Appears to compile fine)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error: Could not find or load main class zoo

So, I was trying to break out of my IDE shell and use the command line...

I wrote the following zoo.java file:

**************************************

**************************************

(Super advanced, I know... lol)

and saved that to C:\Users\Admin\Desktop\testjava\zoo.java

I open the command prompt, browse to the testjava directory and compile:

javac zoo.java

(I have also tried: javac -cp . zoo.java)

Both of which generate the zoo.class file. Then I try to run:

java zoo

(I have also tried java zoo.class)

and get the following error:
Error: Could not find or load main class zoo

Echoing %classpath% I get:
%classpath%

Which, correct me if I am wrong, means it is unset, and will default to the current directory.

I did some Google'ing and tried some different things, such as setting the classpath variable to the JRE install and pointing directly to the rt.jar (did not work).
I have since reset/cleared the value of classpath so it is back to default.

What am I missing?
 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

try:

java Zoo

instead of

java zoo

 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Mitchell wrote:What am I missing?


Java is case-sensitive. "Zoo" is NOT the same as "zoo"
 
Matthew Mitchell
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Holy crap.... I can't believe I missed that...

THANK YOU!
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem. And welcome to the Ranch!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic