简体   繁体   中英

Java main method not found error on Windows 10 even with correct main signature

I have a couple of Java files A.java and B.java that use a common jar file C.jar. B.java contains reference variables to the object of type ABjava contains the main method

I compiled using the following command.

javac -cp C.jar A.java B.java

It compiles.

However, when I run it says main method not found.

I ran

java -cp C.jar B 

Am I making some mistake in my commands?

Am I making some mistake in my commands?

Yes - you're not including anything apart from C.jar when trying to run.

Use

java -cp C.jar;. // Windows
java -cp C.jar:. // Unix

So that you're including the current directory (which is where A.class and B.class are, presumably) on the classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM