0

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?

2 Answers 2

1

On Unix: java -cp MyApp.jar:./libs/third.jar com.packagename.MainClass

On Windows: use ; instead of : and also \ instead of /

Sign up to request clarification or add additional context in comments.

Comments

0

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" } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.