Adding an external class in the class path while executing gradle-shadow fat/uber jar


(sandeepsdixit) #1

I have a fat/uber jar uber-all.jar with main-classpath created using Shadow plugin. It runs fine with java -jar as below:
java -jar uber-all.jar

Now I need to pass an external class to the class path, something like:
java -cp .:Test.class -jar uber-all.jar

It however fails with Test ClassNotFoundException. Is what I am trying to do possible/permitted with fat/uber-jar?

Thanks,
Sandeep


(sandeepsdixit) #2

I resolved this by using just -cp instead of -jar (as -jar ignores -cp):
java -cp .:Test.class:uber-all.jar Main