Reputation: 824
Parent root = FXMLLoader.load(getClass().getResource("kibAr//kibArPerson.fxml"));
line 12 kibAr package in src package
C:\>java -jar person.jar
Exception in Application start method
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(
Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/14832625.run(Unknow
n Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at kibAr.AnaEkran.start(AnaEkran.java:18)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153
(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/25863743.run(Unkno
wn Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown
Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/27949311.run(Unkno
wn Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Sourc
e)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/13569241.run(Unkno
wn Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown S
ource)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/31743054.run(Unkno
wn Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/7345883.run(Unknown So
urce)
... 1 more
I was create jar file with Eclipse (export > Runnable jar file) after when i run jar file not showing window..
After i run jar file from cmd and i show this error. How i can solve this problem?
Upvotes: 0
Views: 1010
Reputation: 18415
Since you didn't show a reproducible example and there can be a few things that go wrong, here's an example that does work:
Create a package application and put this class into it:
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("/application/Test.fxml"));
Scene scene = new Scene(root,400,400);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
Create a "Test.fxml" in the package application.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
<children>
<Pane layoutX="-125.0" layoutY="-143.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Button layoutX="134.0" layoutY="161.0" mnemonicParsing="false" text="Button" />
</children>
</Pane>
</children>
</AnchorPane>
In Eclipse select
Export -> Runnable JAR file -> Extract required libraries into generated JAR
(of course you need to specify the proper launch configuration)
The generated JAR can be executed.
If you have something else, you have to show it if you want help.
Upvotes: 1