I want to specify PropertiesLauncher when starting the jar package, but it doesn't work,

java -jar agent-demo-0.0.1-SNAPSHOT.jar -Dloader.path=/libs/ org.springframework.boot.loader.PropertiesLauncher

But I can execute it normally using the following cmd,

java -cp agent-demo-0.0.1-SNAPSHOT.jar -Dloader.path=/libs/ org.springframework.boot.loader.PropertiesLauncher

It just seems like the difference between -jar and -cp

Comment From: wilkinsona

java -jar does not allow you to specify the main class:

$ java --help
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

Comment From: brucelwl

@wilkinsona Thank you very much for your reply. I have also identified this key point and closed the issue