• Post Reply Bookmark Topic Watch Topic
  • New Topic

class loader error  RSS feed

 
Gursewak Singh
Ranch Hand
Posts: 79
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one of my friend has instaled java 7 when we compile a program it compile well but when we run it gives a error
"could not find or load main class Ab.class".
enviromental variable are set
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is maybe because you are trying to run it with a command like: java Ab.class
you should instead be running it with: java Ab (without the .class).

The Java launcher expects a class name (Ab), not a filename (Ab.class).
 
Ankush Kaundal
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give the classpath using -cp argument and then try to run it.

Say if your class file is in D:\JavaPrograms folder then run it using java -cp D:\javaPrograms Ab
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Disagree. It is most likely Jesper was correct.
 
Ankush Kaundal
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Disagree. It is most likely Jesper was correct.


That what is said by jesper is also right but still the system will not be able to find classpath of the program and then you have to use this argument.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!