• Post Reply Bookmark Topic Watch Topic
  • New Topic

runing .class  RSS feed

 
Prince Banga
Greenhorn
Posts: 3
Android Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a hello world code in wordpad and saved it as MyFirstApp.java. I compiled it with javac and got MyFirstApp.class. When I do

java C:\Users\user\Documents\Java\Projects\MyFirstApp.class

or

cd C:\Users\user\Documents\Java\Projects
java MyFirstApp.class

I get "Could not find or load main class MyFirstApp.class"
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You just need to leave off the ".class" suffix and it should work.
 
Prince Banga
Greenhorn
Posts: 3
Android Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Welcome to the Ranch.

You just need to leave off the ".class" suffix and it should work.


thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not just a matter of leaving the ".class" filename extension off.

The java command takes a class name, not a filename.

If you would do: java C:\Users\user\Documents\Java\Projects\MyFirstApp then it would still not work, because C:\Users\user\Documents\Java\Projects\MyFirstApp is not a class name.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!