new File(URI)
only works for file:
URIs. When a classloader finds a resource in a jar, it returns a jar
URI, for example jar:file:/C:/Program%20Files/test.jar!/foo/bar
.
Fundamentally, the File
class is for files on the filesystem. You can't use it to represent a file within a JAR or another archive. You're going to have to copy the file out of the jar and into a regular file, then create a File
referencing this new file. To read the file from the jar, you could use JarURLConnection.getInputStream with the URL you have, or you could call ClassLoader.getResourceAsStream.