Reputation: 42520
I built a spring-boot application and make the jar file exectuable. There is a compileOnly
dependency on my project which need to be provided at runtime. When I run java -jar myApp.jar
I will get ClassNotFound exeception which is expected. But I don't know how to add the additional jar file on java
command. I have tried below command:
java -Dloader.path=/libs/third.jar -jar myApp.jar
but it doesn't work. How can I add /libs/third.jar
on my application?
Upvotes: 0
Views: 1443
Reputation: 308
On Unix:
java -cp MyApp.jar:./libs/third.jar com.packagename.MainClass
On Windows: use ;
instead of :
and also \
instead of /
Upvotes: 1
Reputation: 42520
After some searching I figured out the problem with -Dloader.path
. In order to make it works I need to change the project layout to be ZIP
which will use PropertiesLauncher
. Below is the configuration.
springBoot {
executable = true
layout = "ZIP"
}
Upvotes: 0