aspose file tools
The moose likes Beginning Java and the fly likes class loader error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "class loader error " Watch "class loader error " New topic
Author

class loader error

Gursewak Singh
Ranch Hand

Joined: Jan 09, 2011
Posts: 65

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
Bartender

Joined: Aug 16, 2005
Posts: 11642

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).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Ankush Kaundal
Greenhorn

Joined: May 12, 2011
Posts: 14
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
Sheriff

Joined: Oct 13, 2005
Posts: 26716
Disagree. It is most likely Jesper was correct.
Ankush Kaundal
Greenhorn

Joined: May 12, 2011
Posts: 14
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.
 
jQuery in Action, 2nd edition
 
subject: class loader error
 
Threads others viewed
unable to compile class for jsp
Regarding "javac" compiler
Mock Test Que...
Does not compile vs Compiles with Error? (John Hunt Mock Exam)
RMI Interface: Synchronise method ?
developer file tools