javacpp icon indicating copy to clipboard operation
javacpp copied to clipboard

java.net.MalformedURLException: Unknown protocol: jar

Open jeffgennari opened this issue 2 years ago • 4 comments

I've encountered a problem accessing classes with newer versions of java:

Uncaught Exception: java.lang.UnsatisfiedLinkError: java.net.MalformedURLException: Unknown protocol: jar java.lang.UnsatisfiedLinkError: java.net.MalformedURLException: Unknown protocol: jar at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1759) at org.bytedeco.javacpp.Loader.load(Loader.java:1345) at org.bytedeco.javacpp.Loader.load(Loader.java:1157) at org.bytedeco.javacpp.Loader.load(Loader.java:1133)

The interesting thing is that this only seems to happen with later versions of Java (15+). When I run the same code in Java11, i do not get this error?

jeffgennari avatar Jun 16 '22 17:06 jeffgennari

That's probably not related to the Java version, but to one of your libraries incorrectly overriding the URL protocol.

saudet avatar Jun 16 '22 22:06 saudet

I'm not sure, things work fine in Java 11, but not Java 17 with all other libraries unchanged

jeffgennari avatar Jun 30 '22 12:06 jeffgennari

I've just given JavaCPP a spin with Maven 3.8.4 and JDK 17! While I'm getting a java.lang.reflect.InaccessibleObjectException from the OSGi tests (@timothyjward Is OSGi incompatible with JDK 17?), apart from that, all tests pass normally.

@jeffgennari What happens if you try to build JavaCPP from source with mvn clean install -Djavacpp.platform=linux-x86_64?

saudet avatar Jul 27 '22 03:07 saudet

@timothyjward Is OSGi incompatible with JDK 17?

I’m not aware of anything at a spec level, although some of the Java changes have caused issues for older implementations. It is probably as simple as needing to update the version of the OSGi framework implementation running the tests.

The current dependency is https://github.com/bytedeco/javacpp/blob/8eaa43ab6088626686b7e7fca047cf633ce8eaf8/src/it/osgi/pom.xml#L161

but the latest release is 7.0.5.

If just updating the version doesn’t fix it then it may also be necessary to add some JVM “opens” flags when launching. This will be related to how frameworks have implemented things internally.

timothyjward avatar Jul 27 '22 07:07 timothyjward