今天想清理一下Linux主机上的一些无用内容,结果发现好多java -cp启动的东西,命令是这样的
java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.13.jar:/opt/maven/boot/plexus-classworlds-2.5.2.jar:/opt/maven/conf/logging jenkins.maven3.agent.Maven33Main /opt/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar
于是乎对java -cp产生了好奇
分解上面命令
指定主类
java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.13.jar:/opt/maven/boot/plexus-classworlds-2.5.2.jar:/opt/maven/conf/logging jenkins.maven3.agent.Maven33Main
指定主类入参(用空格间隔)
/opt/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar
java -cp
-cp就是指定引入的一些需要的jar文件路径,最后指定一个主类
java -cp jar路径1:jar路径2:jar路径3:... 主类 参数1 参数2 ...