There might be a mistake with the jar path. If you want to load class foo.bar.Clazz
, you should be able to find file foo/bar/Clazz.class
in the fat jar file.
I can use your approach above to load any class from a fat jar created with sbt-assembly without problem.
Try using the absolute file path. Verify that new File(jarName).isFile
returns true
.
The URLClassLoader
requires that the classes are directly accessible inside the jar. Nested jars are not supported.