When calling java command line using the -jar
option:
java -jar connector-plugin-client.jar
Can you include additional libraries with -cp
?
java -jar connector-plugin-client.jar -cp ojdbc8.jar
I know I can do
java -cp "connector-plugin-client.jar:ojdbc8.jar" the.main.MainClass
But wondering if that was necessary.
No, you cannot. When using -jar
, the class path is entirely defined by the jar itself and the Class-Path
entry in the META-INF/MANIFEST.MF
file inside the jar. It is not possible to add additional jars or directories to the class path using -cp
.
In other words, -cp
and -jar
are mutually exclusive: you must choose one or the other.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.