Netbeans- Exception in Application start method java.lang.reflect.InvocationTargetException












1















This is my controller:



package projectaddflight;

import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class FXMLDocumentController implements Initializable {

@FXML
private TextField departureTime;

@FXML
private TextField flightNum;

@FXML
private TextField dest;

@FXML
private TextField flightDate;

@FXML
private TextField departureCity;

@FXML
private TextField arrivalTime;

@FXML
private TextArea Output;

@FXML
void save(ActionEvent event) {

String DepartureTime = departureTime.getText();
String FlightNum = flightNum.getText();
String Dest = dest.getText();
String FlightDate = flightDate.getText();
String ArrivalTime = arrivalTime.getText();
String DepartureCity = departureCity.getText();

try (Formatter output = new Formatter("flights.txt"))
{

try
{output.format("%s %s %s %s %s %s%n", FlightNum, FlightDate, DepartureCity, Dest, DepartureTime, ArrivalTime);}
catch (NoSuchElementException elementException)
{Output.setText("Please fill out all fields.");}

}
catch (SecurityException | FileNotFoundException | FormatterClosedException e)
{
e.printStackTrace();
}

Output.setText("Flight #" + FlightNum + " has been set.");


}

@Override
public void initialize(URL location, ResourceBundle resources) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}


My fxml file:



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" fx:id="root" prefHeight="462.0" prefWidth="473.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.101" fx:controller="projectaddflight.FXMLDocumentController">
<children>
<TextField fx:id="flightNum" layoutX="185.0" layoutY="86.0" />
<Label layoutX="78.0" layoutY="91.0" text="Flight Number:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="67.0" layoutY="158.0" text="Destination City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="77.0" layoutY="191.0" text="Departure City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="68.0" layoutY="224.0" text="Departure Time:" AnchorPane.bottomAnchor="89.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="300.0" AnchorPane.topAnchor="224.0" />
<Label layoutX="91.0" layoutY="224.0" text="Arrival Time:" AnchorPane.rightAnchor="299.0" />
<TextField fx:id="dest" layoutX="185.0" layoutY="153.0" />
<TextField fx:id="departureCity" layoutX="185.0" layoutY="186.0" />
<TextField fx:id="departureTime" layoutX="185.0" layoutY="219.0" />
<TextField fx:id="arrivalTime" layoutX="185.0" layoutY="252.0" />
<Label layoutX="189.0" layoutY="22.0" text="Add a Flight">
<font>
<Font size="19.0" />
</font>
</Label>
<Label layoutX="99.0" layoutY="125.0" text="Flight Date:" AnchorPane.rightAnchor="300.0" />
<TextField fx:id="flightDate" layoutX="185.0" layoutY="120.0" />
<Button layoutX="388.0" layoutY="279.0" mnemonicParsing="false" onAction="#save" text="Save" />
<TextArea fx:id="Output" layoutX="41.0" layoutY="318.0" prefHeight="75.0" prefWidth="401.0" />
</children>
</AnchorPane>


and my file:



package projectaddflight;

import java.io.File;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author Simca
*/
public class ProjectAddFlight extends Application {

@Override
public void start(Stage stage) throws Exception {
URL url = new File("src/projectaddflight/FXMLDocument.fxml").toURL();
Parent root = FXMLLoader.load(url);

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String args) {
launch(args);
}

}


and the error code:



Executing /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175/ProjectAddFlight.jar using platform /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/bin/java
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:745)
Caused by: javafx.fxml.LoadException:
/Users/Simca/NetBeansProjects/projectAddFlight/src/projectaddflight/FXMLDocument.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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 projectaddflight.ProjectAddFlight.start(ProjectAddFlight.java:25)
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)
Caused by: java.lang.UnsupportedOperationException: Not supported yet.
at projectaddflight.FXMLDocumentController.initialize(FXMLDocumentController.java:78)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Exception running application projectaddflight.ProjectAddFlight
Java Result: 1
Deleting directory /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175
jfxsa-run:
BUILD SUCCESSFUL (total time: 2 seconds)


I've tried every way of typing the link to the fxml file. I've looked online but haven't seen this exact issue. It was originally the generic "name".java file before I tried to figure out the bug, and even the normal file wasn't working.










share|improve this question























  • You are throwing an exception in the initialize method of the controller that's why you get it

    – Amine Messaoudi
    Nov 23 '18 at 21:17











  • I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

    – Simca Wood
    Nov 23 '18 at 22:03











  • Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

    – skomisa
    Nov 24 '18 at 3:00













  • Thank you so much. So mush frustration for such a simple issue.

    – Simca Wood
    Nov 24 '18 at 22:06
















1















This is my controller:



package projectaddflight;

import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class FXMLDocumentController implements Initializable {

@FXML
private TextField departureTime;

@FXML
private TextField flightNum;

@FXML
private TextField dest;

@FXML
private TextField flightDate;

@FXML
private TextField departureCity;

@FXML
private TextField arrivalTime;

@FXML
private TextArea Output;

@FXML
void save(ActionEvent event) {

String DepartureTime = departureTime.getText();
String FlightNum = flightNum.getText();
String Dest = dest.getText();
String FlightDate = flightDate.getText();
String ArrivalTime = arrivalTime.getText();
String DepartureCity = departureCity.getText();

try (Formatter output = new Formatter("flights.txt"))
{

try
{output.format("%s %s %s %s %s %s%n", FlightNum, FlightDate, DepartureCity, Dest, DepartureTime, ArrivalTime);}
catch (NoSuchElementException elementException)
{Output.setText("Please fill out all fields.");}

}
catch (SecurityException | FileNotFoundException | FormatterClosedException e)
{
e.printStackTrace();
}

Output.setText("Flight #" + FlightNum + " has been set.");


}

@Override
public void initialize(URL location, ResourceBundle resources) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}


My fxml file:



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" fx:id="root" prefHeight="462.0" prefWidth="473.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.101" fx:controller="projectaddflight.FXMLDocumentController">
<children>
<TextField fx:id="flightNum" layoutX="185.0" layoutY="86.0" />
<Label layoutX="78.0" layoutY="91.0" text="Flight Number:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="67.0" layoutY="158.0" text="Destination City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="77.0" layoutY="191.0" text="Departure City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="68.0" layoutY="224.0" text="Departure Time:" AnchorPane.bottomAnchor="89.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="300.0" AnchorPane.topAnchor="224.0" />
<Label layoutX="91.0" layoutY="224.0" text="Arrival Time:" AnchorPane.rightAnchor="299.0" />
<TextField fx:id="dest" layoutX="185.0" layoutY="153.0" />
<TextField fx:id="departureCity" layoutX="185.0" layoutY="186.0" />
<TextField fx:id="departureTime" layoutX="185.0" layoutY="219.0" />
<TextField fx:id="arrivalTime" layoutX="185.0" layoutY="252.0" />
<Label layoutX="189.0" layoutY="22.0" text="Add a Flight">
<font>
<Font size="19.0" />
</font>
</Label>
<Label layoutX="99.0" layoutY="125.0" text="Flight Date:" AnchorPane.rightAnchor="300.0" />
<TextField fx:id="flightDate" layoutX="185.0" layoutY="120.0" />
<Button layoutX="388.0" layoutY="279.0" mnemonicParsing="false" onAction="#save" text="Save" />
<TextArea fx:id="Output" layoutX="41.0" layoutY="318.0" prefHeight="75.0" prefWidth="401.0" />
</children>
</AnchorPane>


and my file:



package projectaddflight;

import java.io.File;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author Simca
*/
public class ProjectAddFlight extends Application {

@Override
public void start(Stage stage) throws Exception {
URL url = new File("src/projectaddflight/FXMLDocument.fxml").toURL();
Parent root = FXMLLoader.load(url);

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String args) {
launch(args);
}

}


and the error code:



Executing /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175/ProjectAddFlight.jar using platform /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/bin/java
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:745)
Caused by: javafx.fxml.LoadException:
/Users/Simca/NetBeansProjects/projectAddFlight/src/projectaddflight/FXMLDocument.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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 projectaddflight.ProjectAddFlight.start(ProjectAddFlight.java:25)
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)
Caused by: java.lang.UnsupportedOperationException: Not supported yet.
at projectaddflight.FXMLDocumentController.initialize(FXMLDocumentController.java:78)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Exception running application projectaddflight.ProjectAddFlight
Java Result: 1
Deleting directory /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175
jfxsa-run:
BUILD SUCCESSFUL (total time: 2 seconds)


I've tried every way of typing the link to the fxml file. I've looked online but haven't seen this exact issue. It was originally the generic "name".java file before I tried to figure out the bug, and even the normal file wasn't working.










share|improve this question























  • You are throwing an exception in the initialize method of the controller that's why you get it

    – Amine Messaoudi
    Nov 23 '18 at 21:17











  • I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

    – Simca Wood
    Nov 23 '18 at 22:03











  • Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

    – skomisa
    Nov 24 '18 at 3:00













  • Thank you so much. So mush frustration for such a simple issue.

    – Simca Wood
    Nov 24 '18 at 22:06














1












1








1








This is my controller:



package projectaddflight;

import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class FXMLDocumentController implements Initializable {

@FXML
private TextField departureTime;

@FXML
private TextField flightNum;

@FXML
private TextField dest;

@FXML
private TextField flightDate;

@FXML
private TextField departureCity;

@FXML
private TextField arrivalTime;

@FXML
private TextArea Output;

@FXML
void save(ActionEvent event) {

String DepartureTime = departureTime.getText();
String FlightNum = flightNum.getText();
String Dest = dest.getText();
String FlightDate = flightDate.getText();
String ArrivalTime = arrivalTime.getText();
String DepartureCity = departureCity.getText();

try (Formatter output = new Formatter("flights.txt"))
{

try
{output.format("%s %s %s %s %s %s%n", FlightNum, FlightDate, DepartureCity, Dest, DepartureTime, ArrivalTime);}
catch (NoSuchElementException elementException)
{Output.setText("Please fill out all fields.");}

}
catch (SecurityException | FileNotFoundException | FormatterClosedException e)
{
e.printStackTrace();
}

Output.setText("Flight #" + FlightNum + " has been set.");


}

@Override
public void initialize(URL location, ResourceBundle resources) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}


My fxml file:



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" fx:id="root" prefHeight="462.0" prefWidth="473.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.101" fx:controller="projectaddflight.FXMLDocumentController">
<children>
<TextField fx:id="flightNum" layoutX="185.0" layoutY="86.0" />
<Label layoutX="78.0" layoutY="91.0" text="Flight Number:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="67.0" layoutY="158.0" text="Destination City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="77.0" layoutY="191.0" text="Departure City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="68.0" layoutY="224.0" text="Departure Time:" AnchorPane.bottomAnchor="89.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="300.0" AnchorPane.topAnchor="224.0" />
<Label layoutX="91.0" layoutY="224.0" text="Arrival Time:" AnchorPane.rightAnchor="299.0" />
<TextField fx:id="dest" layoutX="185.0" layoutY="153.0" />
<TextField fx:id="departureCity" layoutX="185.0" layoutY="186.0" />
<TextField fx:id="departureTime" layoutX="185.0" layoutY="219.0" />
<TextField fx:id="arrivalTime" layoutX="185.0" layoutY="252.0" />
<Label layoutX="189.0" layoutY="22.0" text="Add a Flight">
<font>
<Font size="19.0" />
</font>
</Label>
<Label layoutX="99.0" layoutY="125.0" text="Flight Date:" AnchorPane.rightAnchor="300.0" />
<TextField fx:id="flightDate" layoutX="185.0" layoutY="120.0" />
<Button layoutX="388.0" layoutY="279.0" mnemonicParsing="false" onAction="#save" text="Save" />
<TextArea fx:id="Output" layoutX="41.0" layoutY="318.0" prefHeight="75.0" prefWidth="401.0" />
</children>
</AnchorPane>


and my file:



package projectaddflight;

import java.io.File;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author Simca
*/
public class ProjectAddFlight extends Application {

@Override
public void start(Stage stage) throws Exception {
URL url = new File("src/projectaddflight/FXMLDocument.fxml").toURL();
Parent root = FXMLLoader.load(url);

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String args) {
launch(args);
}

}


and the error code:



Executing /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175/ProjectAddFlight.jar using platform /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/bin/java
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:745)
Caused by: javafx.fxml.LoadException:
/Users/Simca/NetBeansProjects/projectAddFlight/src/projectaddflight/FXMLDocument.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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 projectaddflight.ProjectAddFlight.start(ProjectAddFlight.java:25)
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)
Caused by: java.lang.UnsupportedOperationException: Not supported yet.
at projectaddflight.FXMLDocumentController.initialize(FXMLDocumentController.java:78)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Exception running application projectaddflight.ProjectAddFlight
Java Result: 1
Deleting directory /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175
jfxsa-run:
BUILD SUCCESSFUL (total time: 2 seconds)


I've tried every way of typing the link to the fxml file. I've looked online but haven't seen this exact issue. It was originally the generic "name".java file before I tried to figure out the bug, and even the normal file wasn't working.










share|improve this question














This is my controller:



package projectaddflight;

import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class FXMLDocumentController implements Initializable {

@FXML
private TextField departureTime;

@FXML
private TextField flightNum;

@FXML
private TextField dest;

@FXML
private TextField flightDate;

@FXML
private TextField departureCity;

@FXML
private TextField arrivalTime;

@FXML
private TextArea Output;

@FXML
void save(ActionEvent event) {

String DepartureTime = departureTime.getText();
String FlightNum = flightNum.getText();
String Dest = dest.getText();
String FlightDate = flightDate.getText();
String ArrivalTime = arrivalTime.getText();
String DepartureCity = departureCity.getText();

try (Formatter output = new Formatter("flights.txt"))
{

try
{output.format("%s %s %s %s %s %s%n", FlightNum, FlightDate, DepartureCity, Dest, DepartureTime, ArrivalTime);}
catch (NoSuchElementException elementException)
{Output.setText("Please fill out all fields.");}

}
catch (SecurityException | FileNotFoundException | FormatterClosedException e)
{
e.printStackTrace();
}

Output.setText("Flight #" + FlightNum + " has been set.");


}

@Override
public void initialize(URL location, ResourceBundle resources) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}


My fxml file:



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" fx:id="root" prefHeight="462.0" prefWidth="473.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.101" fx:controller="projectaddflight.FXMLDocumentController">
<children>
<TextField fx:id="flightNum" layoutX="185.0" layoutY="86.0" />
<Label layoutX="78.0" layoutY="91.0" text="Flight Number:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="67.0" layoutY="158.0" text="Destination City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="77.0" layoutY="191.0" text="Departure City:" AnchorPane.rightAnchor="300.0" />
<Label layoutX="68.0" layoutY="224.0" text="Departure Time:" AnchorPane.bottomAnchor="89.0" AnchorPane.leftAnchor="68.0" AnchorPane.rightAnchor="300.0" AnchorPane.topAnchor="224.0" />
<Label layoutX="91.0" layoutY="224.0" text="Arrival Time:" AnchorPane.rightAnchor="299.0" />
<TextField fx:id="dest" layoutX="185.0" layoutY="153.0" />
<TextField fx:id="departureCity" layoutX="185.0" layoutY="186.0" />
<TextField fx:id="departureTime" layoutX="185.0" layoutY="219.0" />
<TextField fx:id="arrivalTime" layoutX="185.0" layoutY="252.0" />
<Label layoutX="189.0" layoutY="22.0" text="Add a Flight">
<font>
<Font size="19.0" />
</font>
</Label>
<Label layoutX="99.0" layoutY="125.0" text="Flight Date:" AnchorPane.rightAnchor="300.0" />
<TextField fx:id="flightDate" layoutX="185.0" layoutY="120.0" />
<Button layoutX="388.0" layoutY="279.0" mnemonicParsing="false" onAction="#save" text="Save" />
<TextArea fx:id="Output" layoutX="41.0" layoutY="318.0" prefHeight="75.0" prefWidth="401.0" />
</children>
</AnchorPane>


and my file:



package projectaddflight;

import java.io.File;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author Simca
*/
public class ProjectAddFlight extends Application {

@Override
public void start(Stage stage) throws Exception {
URL url = new File("src/projectaddflight/FXMLDocument.fxml").toURL();
Parent root = FXMLLoader.load(url);

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String args) {
launch(args);
}

}


and the error code:



Executing /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175/ProjectAddFlight.jar using platform /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/bin/java
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:745)
Caused by: javafx.fxml.LoadException:
/Users/Simca/NetBeansProjects/projectAddFlight/src/projectaddflight/FXMLDocument.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
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 projectaddflight.ProjectAddFlight.start(ProjectAddFlight.java:25)
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)
Caused by: java.lang.UnsupportedOperationException: Not supported yet.
at projectaddflight.FXMLDocumentController.initialize(FXMLDocumentController.java:78)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Exception running application projectaddflight.ProjectAddFlight
Java Result: 1
Deleting directory /Users/Simca/NetBeansProjects/projectAddFlight/dist/run1675277175
jfxsa-run:
BUILD SUCCESSFUL (total time: 2 seconds)


I've tried every way of typing the link to the fxml file. I've looked online but haven't seen this exact issue. It was originally the generic "name".java file before I tried to figure out the bug, and even the normal file wasn't working.







java netbeans-8






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 21:12









Simca WoodSimca Wood

61




61













  • You are throwing an exception in the initialize method of the controller that's why you get it

    – Amine Messaoudi
    Nov 23 '18 at 21:17











  • I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

    – Simca Wood
    Nov 23 '18 at 22:03











  • Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

    – skomisa
    Nov 24 '18 at 3:00













  • Thank you so much. So mush frustration for such a simple issue.

    – Simca Wood
    Nov 24 '18 at 22:06



















  • You are throwing an exception in the initialize method of the controller that's why you get it

    – Amine Messaoudi
    Nov 23 '18 at 21:17











  • I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

    – Simca Wood
    Nov 23 '18 at 22:03











  • Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

    – skomisa
    Nov 24 '18 at 3:00













  • Thank you so much. So mush frustration for such a simple issue.

    – Simca Wood
    Nov 24 '18 at 22:06

















You are throwing an exception in the initialize method of the controller that's why you get it

– Amine Messaoudi
Nov 23 '18 at 21:17





You are throwing an exception in the initialize method of the controller that's why you get it

– Amine Messaoudi
Nov 23 '18 at 21:17













I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

– Simca Wood
Nov 23 '18 at 22:03





I'm sorry, I'm still so new at GUI's. Where exactly is the exception and how do I fix it?

– Simca Wood
Nov 23 '18 at 22:03













Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

– skomisa
Nov 24 '18 at 3:00







Just delete the line containing throw new UnsupportedOperationException(...); from initialize() to make that method empty. That code is generated by NetBeans, and you don't want it. Possible duplicate of FXML Initialize() throws InvocationTargetException.

– skomisa
Nov 24 '18 at 3:00















Thank you so much. So mush frustration for such a simple issue.

– Simca Wood
Nov 24 '18 at 22:06





Thank you so much. So mush frustration for such a simple issue.

– Simca Wood
Nov 24 '18 at 22:06












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452985%2fnetbeans-exception-in-application-start-method-java-lang-reflect-invocationtarg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452985%2fnetbeans-exception-in-application-start-method-java-lang-reflect-invocationtarg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno