I have a setting like this:
So, I execute external.jar and inside it the main class:
URL url = Main.class.getClassLoader().getResource("file.txt");
url is: 'jar: file: outer.jar! /inner.jar! /file.txt'
But if I try to read it like:
url.openStream()
I get an exception
Exception in thread "main" java.io.FileNotFoundException: JAR entry inner.jar!/file.txt not found in outer.jar at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:142) at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150) at java.net.URL.openStream(URL.java:1038) at Main.main(Main.java:15)
The file definitely exists. Is this not possible with JarURLConnection?
source share