Мне пришлось переключиться на openJDK из JDK8, и я не могу скомпилировать свою программу с помощью maven. Это новое для меня, и после нескольких дней поисков в Google я запутался в версиях больше, чем раньше.
Я не смог выяснить:
- Должен ли я использовать последнюю версию? версия openJDK? (в настоящее время 13)
- Должен ли openJFX соответствовать версии openJDK?
- Maven: мне нужно скомпилировать его с исходным и целевым с 13 или возможно с 1,8 добыть совместимым с JRE1.8
Вот что я сделал в Eclipse:
- импортировал openJDK 13 в Eclipse и установил его как JDK по умолчанию.
- обновил pom.xml до компилятора maven 3.8.1 и установил для источника и цели значение 13.
- добавил зависимости openJFX 13
Когда я только что импортировал проект из GIT, он запускается безлюбые ошибки. После того, как я скомпилировал или обновил проект через Maven, я получаю кучу разных ошибок, и программа больше не работает. Я заметил, что maven устанавливает мой Project JRE на [J2SE-1.5] каждый раз, когда я обновляю его. Как мне предотвратить это?
Это действительно странно. Внутри класса я получаю ошибки компилятора, что что-то не может быть найдено, но в моем обозревателе пакетов все выглядит нормально:
Снимок
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>IBE_Calculator</groupId>
<artifactId>IBE_Calculator</artifactId>
<version>IBE</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>main/resources</directory>
<includes>
<include>IBEDB.sqlite</include>
</includes>
</resource>
<resource>
<directory>res</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>13</source>
<target>13</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>main.java.srcMain.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>main.java.srcMain.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/libs2</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-ext</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
<name>IBECalc</name>
</project>
Я чувствую, что в моем коде нет ничего плохого, но вот текущая ошибка:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.Error: Unresolved compilation problems:
The method handle(WindowEvent) of type new EventHandler<WindowEvent>(){} must override a superclass method
The method run() of type new Runnable(){} must override a superclass method
at srcMain.Main$1.handle(Main.java:42)
at srcMain.Main$1.handle(Main.java:1)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.stage.Window.fireEvent(Window.java:1368)
at javafx.stage.Window$12.invalidated(Window.java:1122)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.stage.Window.setShowing(Window.java:1174)
at javafx.stage.Window.show(Window.java:1189)
at javafx.stage.Stage.show(Stage.java:273)
at srcMain.Main.start(Main.java:74)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Я вызываю свой основной класс из нового класса, потому что, похоже, есть ошибка.
Class NewMain:
package srcMain;
public class NewMain {
public static void main(String args[] ) throws Exception {
Main.main(args);
}
}
Class Main:
package srcMain;
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
import SQLite.*;
import javafx.application.*;
import com.sun.javafx.application.*;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.event.*;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
public class Main extends Application{
static SQLite db;
public static Boolean isSplashLoaded = false;
public static Boolean data_fin = false;
public static Stage parentWindow;
Stage stage = new Stage();
@Override
public void start(final Stage primaryStage) throws Exception{
/*
* �ffnet den Loading Screen und startet die Dateneinlesung
*/
try{
parentWindow = primaryStage;
FXMLLoader loader = new FXMLLoader(getClass().getResource("IBE_LoadScreen.fxml"));
loader.setController(new ControllerLoadScreen());
Parent root1 = (Parent)loader.load();
//wenn die GUI angezeigt wird, wird die Dateneinlesung gestartet
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent window){
Platform.runLater(new Runnable(){
@Override
public void run(){
try {
try {
readData();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
data_fin = true;
}
});
}
});
//wird der Close-Button gefr�ckt, schlie�t sich das gesamte Programm, nicht nur das Fenster
Platform.setImplicitExit(false);
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
Platform.exit();
}
});
stage.setResizable(true);
stage.setTitle("Wegeentgelt-Kalkulator");
stage.setScene(new Scene(root1));
stage.show();
}catch(Exception e){
System.out.println("Cant load new window");
e.printStackTrace();
}
}
public void readData() throws SQLException, ParseException {
/*
* erstellt ein ExcelHandler Objekt und ruft alle Methoden auf
* die Daten von den Excel-Files einlesen.
*
* Wenn diese Daten fertig eingelesen wurden, wird die Main-Maske angezeigt.
*/
db.Hst();
db.Halte();
db.Marktsegment();
db.bstn();
db.basisdaten();
db.TFZ();
db.closeConnection();
data_fin = true;
//wenn die Daten eingelesen wurden �ffnet sich die Main-Maske
if(data_fin){
FXMLLoader loader = new FXMLLoader(getClass().getResource("IBECalc-Main_1024_768.fxml"));
loader.setController(new ControllerMain("1024x768"));
Parent root1;
try {
root1 = (Parent)loader.load();
stage.getScene().setRoot(root1);
stage.setResizable(true);
stage.setMinHeight(680);
stage.setMinWidth(1024);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) throws SQLException{
//startet das Programm
db = new SQLite();
launch(args);
}
}
Я импортировал проект в другую среду, и теперь появляется новая ошибка. Не удается найти класс приложения для запуска графического интерфейса.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method launch(String[]) is undefined for the type Main
at srcMain.Main.main(Main.java:123)
at srcMain.NewMain.main(NewMain.java:6)