1

I'm working on an applet that uses JSObject & co. (from plugin.jar) to invoke JavaScript functions on the web page where it's loaded; the project is built using pure mvn: no IDEs, no Jenkins.

My problem arises from the fact that Oracle provides two classes with the exact same FQ name and different method signatures (see JSObject#getWindow()). After upgrading the local JDK to Java8 the build fails on JSObject because it ends up picking it from JavaFX (jfxrt.jar) instead of plugin.jar (alphabetical ordering in classpath?).

I have been looking for a solution here and elsewehere and what I came across is:

  1. explicitly reorder the dependencies in your IDE (but I have no IDE...)
  2. use maven dependencies ordering in the POM (supported since 2.0.X and I'm running on 3.3.9, yet this seems to work for project dependencies, not system JARs)
  3. use exclusions (does not seem to apply to JDK dependencies either)
  4. on Jenkins things seem to be automagically resolved thanks to Jenkins adding the JDK JARs to the build classpath after the project dependencies.

So the question is: is there a way to configure a maven project building against JDK8 so it consistently resolves JSObject from plugin.jar instead of jfxrt.jar on all platforms (Windows, *nix etc.)?

Andrea Funtò
  • 81
  • 1
  • 3
  • 1
    Possible duplicate of [Java, Classpath, Classloading => Multiple Versions of the same jar/project](http://stackoverflow.com/questions/6105124/java-classpath-classloading-multiple-versions-of-the-same-jar-project) – pringi Jan 20 '17 at 13:40
  • My question is about class resolving at compile time (i.e. how to enforce a specific ordering of **different** dependencies having the same class with different signature in the javac classpath), whereas the one mentioned is about runtime class loading. Unfortunately I have no access to the javac classloader, nor am I aware of any way of forcing the JDK to use OSGi to perform its builds. – Andrea Funtò Feb 15 '17 at 09:05

0 Answers0