Reputation: 61
You can use this command to start a jar file and specify a main class.
java -cp file.jar path.to.MainClass
My problem is that I just have a class that is not contained in a package. So the main class is just called MainClass. So the command becomes
java -cp file.jar MainClass
The problem is that java does not seem to be able to load the class and just says it could not be found or loaded.
Is there a way to start a jar with the -cp argument like that?
Upvotes: 1
Views: 120
Reputation: 7027
Just run:
java -cp file.jar MainKt
Main-Class
in manifest only impacts java -cp file.jar
, not when used with a class argument like MainClass
(which presumably doesn't exist) or MainKt
.
Also, if your class is really named MainClass
inside the MainKt.java
source file, it should be renamed to match the source file name (or vice versa) first; see e.g. this question.
Upvotes: 1