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 A. B.java 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?

Jon Skeet
people
quotationmark

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.

people

See more on this question at Stackoverflow