Permalink
Browse files

Made DefaultLauncher JavaFX aware

  • Loading branch information...
mordechaim committed Jan 8, 2019
1 parent d59acba commit d624925c6c725410a956b03f78f36b944576d21e
Showing with 23 additions and 2 deletions.
  1. +23 −2 src/main/java/org/update4j/service/DefaultLauncher.java
@@ -36,6 +36,14 @@ public long version() {
return Long.MIN_VALUE;
}

public DefaultLauncher() {

}

public DefaultLauncher(List<String> args) {
this.args = args;
}

@Override
public void run(LaunchContext context) {
Configuration config = context.getConfiguration();
@@ -60,9 +68,22 @@ public void run(LaunchContext context) {

try {
Class<?> clazz = Class.forName(mainClass, true, context.getClassLoader());
Method method = clazz.getMethod("main", String[].class);

method.invoke(null, new Object[] { argsArray });
// first check for JavaFx start method
Class<?> javafx = null;
try {
javafx = Class.forName("javafx.application.Application", true, context.getClassLoader());
} catch (ClassNotFoundException e) {
// no JavaFx present, skip.
}

if (javafx != null && javafx.isAssignableFrom(clazz)) {
Method launch = javafx.getMethod("launch", Class.class, String[].class);
launch.invoke(null, clazz, argsArray);
} else {
Method main = clazz.getMethod("main", String[].class);
main.invoke(null, new Object[] { argsArray });
}

} catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException
| NoSuchMethodException e) {

0 comments on commit d624925

Please sign in to comment.