我使用JavaFX开发Java应用程序,并实现了地图,因此我在Itellij上使用GMapsFX。 但是我有那个错误:
class Abc {
public final static String ASC = "ASC";
public final static String DESC = "DESC";
public method(String parameter, LinkedList<type>) {
if(!ASC.equalsIgnoreCase(parameter) && !DESC.equalsIgnoreCase(parameter)) {
throw new IllegalArgumentException();
}
if(ASC.equalsIgnoreCase(parameter)) {
do this
} else if(DESC.equalsIgnoreCase(parameter)) {
do that
}
}
}
public void testCatchIllegalArgument() {
boolean passed = false;
try {
sort2.method(Abc.ASC, list5);
} catch (IllegalArgumentException e) {
passed = true;
}
assertEquals("... "
+ " failed.", true, passed);
}
所以对于这个错误,我有一个fxml文件:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.lynden.gmapsfx.GoogleMapView.<clinit>(GoogleMapView.java:55)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(FXMLLoader.java:1009)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:746)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at sample.Main.start(Main.java:24)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 28 more
Exception running application sample.Main
和一个主文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.lynden.gmapsfx.ClusteredGoogleMapView?>
<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ProgressIndicator?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.shape.Circle?>
<GridPane alignment="center" prefHeight="315.0" prefWidth="545.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
<children>
<SplitPane fx:id="slider" dividerPositions="0.29797979797979796" onDragDetected="#slide" prefHeight="2000.0" prefWidth="2000.0" GridPane.rowIndex="1">
<items>
<AnchorPane maxWidth="400.0" minHeight="0.0" minWidth="191.0" prefHeight="168.0">
<children>
<Accordion prefWidth="2000.0">
<panes>
<TitledPane animated="false" text="Giropode">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="200.0" />
</content>
</TitledPane>
<TitledPane animated="false" text="Donnée Drone">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="200.0">
<children>
<ScrollPane prefHeight="400.0" prefWidth="191.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="404.0" prefWidth="288.0">
<children>
<ProgressIndicator layoutX="66.0" layoutY="14.0" progress="0.0" />
</children>
</AnchorPane>
</content>
</ScrollPane>
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Action Bouton">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="200.0">
<children>
<ScrollPane prefHeight="189.0" prefWidth="191.0">
<content>
<AnchorPane maxHeight="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="204.0" prefWidth="170.0">
<children>
<Button fx:id="connexion" layoutY="14.0" mnemonicParsing="false" onMouseClicked="#ConnexionClick" text="Connexion">
<graphic>
<Circle id="circle1" fx:id="circle1" fill="WHITE" radius="6.0" stroke="BLACK" strokeType="INSIDE" />
</graphic>
</Button>
<Button fx:id="Lancement" layoutY="57.0" mnemonicParsing="false" onMouseClicked="#LancementClick" text="Lancement moteur">
<graphic>
<Circle id="circle2" fx:id="circle2" fill="WHITE" radius="6.0" stroke="BLACK" strokeType="INSIDE" />
</graphic>
</Button>
<Button fx:id="Decollage" layoutY="102.0" mnemonicParsing="false" onMouseClicked="#DecollageClick" text="Décollage">
<graphic>
<Circle id="circle3" fx:id="circle3" fill="WHITE" radius="6.0" stroke="BLACK" strokeType="INSIDE" />
</graphic>
</Button>
<Button fx:id="Retour" layoutX="-1.0" layoutY="150.0" mnemonicParsing="false" onMouseClicked="#RetourClick" text="Atterissage">
<graphic>
<Circle id="circle4" fx:id="circle4" fill="WHITE" radius="6.0" stroke="BLACK" strokeType="INSIDE" />
</graphic>
</Button>
</children></AnchorPane>
</content>
</ScrollPane>
</children></AnchorPane>
</content>
</TitledPane>
</panes>
<effect>
<DropShadow />
</effect>
</Accordion>
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="215.0" prefWidth="371.0">
<children>
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="1000.0" prefWidth="2000.0">
<items>
<AnchorPane maxHeight="850.0" minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="160.0">
<children>
<ClusteredGoogleMapView layoutY="6.0" prefHeight="200.0" prefWidth="200.0" />
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="10.0" prefHeight="100.0" prefWidth="160.0" />
</items>
</SplitPane>
</children></AnchorPane>
</items>
</SplitPane>
<MenuBar prefHeight="32.0" prefWidth="2457.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</GridPane>
但是我不知道我的错误在哪里,所以我认为我没有很好的GMapsFX库(我jar的链接:here)
所以我想知道如何解决这个问题