• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could not load main method when setting class path  RSS feed

 
Rajesh Santhanakrishnan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to run a java program in linux server which includes an imported jar.
While compiling it is not giving any issues , but when I try to run, it is giving an error "Error: Could not find or load main class ". If I remove the import and its references , my code is working fine without any load issues.
Any inputs please

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the SamplePwd class in the jar file? Because if it is not, you will need to modify your classpath so that it can find that class file. The reason that the Java compiler is not complaining regarding it, is that it doesn't need to find the SamplePwd class file -- it is generating the class file, and not using (need to load) it.

Henry
 
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
If your class SamplePwd is in the current directory, and it is not in a package (you don't have a package statement at the top of the source file), then you should add the current directory to the classpath as well:

java -cp /opt/CARKaim/sdk/pwdsdk.jar:. SamplePwd

Note: . indicates the current directory, and on Unix-like operating systems : is used to separate path entries. (On Windows you would have to use ; instead of :).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!