• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error when attempting to Execute (Appears to compile fine)  RSS feed

 
Matthew Mitchell
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

try:

java Zoo

instead of

java zoo

 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Holy crap.... I can't believe I missed that...

THANK YOU!
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. And welcome to the Ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!