2

I am reading a excel file using java and i am executing the program with the below command but its giving me error: Could not find or load main class Test

My main class is in the same directory where i am running the program D:\java\Test>java -classpath "D:\java\Test\poi-3.9-20121203.jar;D:\java\Test\poi-ooxml-3.9-20121203.jar Test

Spent whole day to find out why this error is coming please help me out.

Gaurang Tandon
  • 6,504
  • 11
  • 47
  • 84

1 Answers1

1

Basically, there are two main causes:

The first likely cause is that you may have provided the wrong class name. (Or ... the right class name, but in the wrong form.)

The second likely cause is that the class name is correct, but that the java command cannot find the class. To understand this, you need to understand the concept of the "classpath". This is explained well by the Oracle documentation:

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

Setting classpath:

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

The Java Tutorial - http://docs.oracle.com/javase/tutorial/essential/environment/paths.html

For more detail check this link What does "Could not find or load main class" mean?

Bharti Rawat
  • 1,949
  • 21
  • 32