Skip to content

Commit

Permalink
Add IDE warning when wrong libs are in-use
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed May 20, 2020
1 parent c726cfa commit aef8d0c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/qz/printer/action/WebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -143,6 +144,9 @@ public static synchronized void initialize() throws IOException {
// JavaFX native libs
if (SystemUtilities.isJar()) {
System.setProperty("java.library.path", new File(SystemUtilities.detectJarPath()).getParent() + "/libs/");
} else if(hasConflictingLib()) {
// IDE helper for "no suitable pipeline found" errors
System.err.println("\n=== WARNING ===\nWrong javafx platform detected. Delete lib/javafx/<platform> to correct this.\n");
}

// Monocle default for unit tests
Expand Down Expand Up @@ -418,4 +422,16 @@ public static void unlatch(Throwable t) {
stage.hide();
}

public static boolean hasConflictingLib() {
// If running from the IDE, make sure we're not using the wrong libs
URL url = Application.class.getResource("/" + Application.class.getName().replace('.', '/') + ".class");
String graphicsJar = url.toString().replaceAll("file:/|jar:", "").replaceAll("!.*", "");
log.trace("JavaFX will startup using {}", graphicsJar);
if(SystemUtilities.isWindows()) {
return !graphicsJar.contains("windows");
} else if(SystemUtilities.isMac()) {
return !graphicsJar.contains("osx") && !graphicsJar.contains("mac");
}
return !graphicsJar.contains("linux");
}
}

0 comments on commit aef8d0c

Please sign in to comment.