JavaFX-Anwendung kann nicht mit nativem exe-Bundle gestartet werden
Ich habe eine JavaFX-Anwendung erstellt, die von ihrer JAR-Datei ausgeführt werden kann. Wenn ich jedoch versuche, es mit dem nativen exe-Bundle auszuführen, erhalte ich zwei Popups:
com / npap / dicomrouter / Main - keine Hauptklasse
JVM konnte nicht gestartet werden
und die Anwendung startet nicht.
Dies ist meine Hauptklasse (größtenteils):
package com.npap.dicomrouter;
public class Main extends Application {
...
public static void main(String[] args) throws IOException {
try {
JUnique.acquireLock(appId);
alreadyRunning = false;
log.info("application is going to start running!!!!");
} catch (AlreadyLockedException e) {
alreadyRunning = true;
log.info("application is already running!!!!");
}
if (!alreadyRunning) {
Application.launch(Main.class, (java.lang
.String[])null);
}
}
@Override
public void start(Stage primaryStage) throws IOException {
...
try {
AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("FXMLDocument.fxml"));
Scene scene = new Scene(page, initWidth, initHeight);
primaryStage.setScene(scene);
Platform.setImplicitExit(false);
createTrayIcon(primaryStage);
primaryStage.setTitle(appTitle);
primaryStage.show();
} catch (IOException ex) {
log.log(Level.INFO, null, ex);
}
}
Meine build.xml ist folgendermaßen konfiguriert:
<target name="-post-jfx-deploy">
<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
nativeBundles="all"
outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}"
mainClass="${javafx.main.class}"/>
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}"
includes="*.jar"/>
</fx:resources>
<fx:info title="${application.title}"
vendor="${application.vendor}"/>
</fx:deploy>
</target>
Ich erstelle die Anwendung (Java FX 2.1) mit Netbeans, wie hier beschrieben:
https: //netbeans.org/kb/docs/java/native_pkg.htm
und ich habe Erfolg, lly bauen und andere Javafx-Anwendungen mit nativen exe-Bundle ausführen. Ich füge auch einen Screenshot bei, der zeigt, wie ich die Klasse des Hauptprojekts deklariere.
So gehe ich zutiefst davon aus, dass dies ein projektspezifisches Problem ist. Während des Einbaus der Konsole erhalte ich:
The jar lib\hibernate-commons-annotations-4.0.2.Final.jar has a main class org.hibernate.annotations.common.Version that does not match the declared main com.xxxx.yyyy.Main
The jar lib\javassist-3.15.0-GA.jar has a main class javassist.CtClass that does not match the declared main com.xxxx.yyyy.Main
The jar lib\h2-1.3.176.jar has a main class org.h2.tools.Console that does not match the declared main com.xxxx.yyyy.Main
Abgesehen von diesen Gläsern verwende ich mehrere andere Klassen, die "main" -Methoden enthalten (können ausgeführt werden).
@SuppressWarnings("unchecked")
public static void main(String args[]) throws Exception {
...
Die meisten von ihnen sind Dienstprogrammklassen von Drittanbietern.
Ich füge auch den Inhalt der Datei package.cfg nur zu Ihrer Information hinzu:
app.mainjar=DicomRouterAffidea0_2_2.jar
app.version=1.0
app.id=com.npap.dicomrouter
app.preferences.id=com/npap/dicomrouter
app.mainclass=com/npap/dicomrouter/Main
app.classpath=lib/antlr-2.7.7.jar lib/c3p0-0.9.2.1.jar lib/clibwrapper_jiio.jar .....
... //jars listing
Abschließend füge ich 3 Screenshots der Konfiguration von Libraries, Compiling and Deployment Netbeans bei. Hoffe das kann auch helfen: