I'm having a problem compiling and running the Java class containing my main method. My code is similar to:
public import myLib.LibClass;
public class MyMainClass extends LibClass{
public static void main(String[] args) {
...
}
@override
public void LibClassFunction(){...}
}
In which LibClass is an abstract class coming from an already compiled .jar file, of which I have to implement a specific abstract function. I can compile without problems with
javac -cp ./myLib.jar MyMainClass.java
However, I'm not managing to run it with the "java" command, getting the error
Error: Could not find or load main class MyMainClass
, even if MyMainClass doesn't have any package.
Thank you in advance!
答案 0 :(得分:2)
The command line you need is
java -cp myLib.jar:. MyMainClass
You need to provide the stuff that your class depends on.
Separator should be ;
, not :
, on Unix, Linux, HP-UX, AIX, Solaris, etc.