My project uses springboot, after pack it to jar file, I can execute java -jar my-project.jar
to run the instance.
I also have a script which is a main class, when I execute java -cp my-project.jar com.test.MyScript
, it says Could not find or load main class
.
How can this happen? By the way, when I execute java -cp my-project.jar com.test.MyApplication
, the same error occurs. MyApplication
is the SpringBootApplication
class.
Why can't I manually run the main class?