Question
please help getting these errors Copying 12 files to C:UsersMichaDocumentsJavaRegistrationdist un1836710519 jfx-project-run: Executing C:UsersMichaDocumentsJavaRegistrationdist un1836710519Registration.jar using platform C:Program FilesJavajdk1.8.0_221jre/bin/java Exception in Application start method Exception
please help getting these errors
Copying 12 files to C:\Users\Micha\Documents\Java\Registration\dist un1836710519 jfx-project-run: Executing C:\Users\Micha\Documents\Java\Registration\dist un1836710519\Registration.jar using platform C:\Program Files\Java\jdk1.8.0_221\jre/bin/java 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(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$1(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:748) Caused by: javafx.fxml.LoadException: file:/C:/Users/Micha/Documents/Java/Registration/dist/run1836710519/Registration.jar!/registration/FXMLDocument.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601) at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103) at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922) at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971) at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220) at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744) 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 registration.Registration.start(Registration.java:19) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$3(WinApplication.java:177) ... 1 more Caused by: java.lang.ClassNotFoundException: FXMLDocumentController at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920) ... 22 more Java Result: 1 Deleting directory C:\Users\Micha\Documents\Java\Registration\dist un1836710519 jfxsa-run: BUILD SUCCESSFUL (total time: 2 seconds)
Registration.java File:
//exection starts from this file
//import the javafx class import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage;
public class Registration extends Application {
@Override public void start(Stage stage) throws Exception { //exceution starts from here Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); //load FXMLDocument.fxml file in the Parent objrct root
Scene scene = new Scene(root); //create a scene i.e. the container that will display the window containing root
stage.setScene(scene); // set the scene in the stage stage.setResizable(false); //set resizable to false meaning the user cannot change the window size stage.setTitle("Student Registration"); //set the title of the window stage.show(); //make the window visible
}
}
FXMLDocument.fxml file:
FXMLDocumentController.java file:
//controller file determines the action that the program needs to take when user interacts with the GUI
import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.Button; import javafx.stage.Stage;
public class FXMLDocumentController implements Initializable { //creating instane of Label class for the label named label present in fxml file @FXML private Label label; @FXML //creating instane of TextField class for the textfield named firstName present in fxml file private TextField firstName; @FXML private TextField lastName; @FXML private TextField year; @FXML private TextField paasword; @FXML //creating instane of button class for the button named buttonExit present in fxml file private Button buttonExit;
//when user clicks on button buttonRegister this function gets exectued @FXML private void handleButtonAction(ActionEvent event) { //check whether user has not entered any value in either textField firstName,lastName and year if(firstName.getText().equals("") || lastName.getText().equals("") || year.getText().equals("")) { label.setText("Please enter first and last name and year of birth"); //ask user to enter details paasword.setText(""); } else{ //if the user had entered all the details. set the value of paasword textfield label.setText("Hello "+firstName.getText()+" "+lastName.getText()+"!" ); paasword.setText(firstName.getText()+"*"+year.getText());
}
} //when user clicks on the exit button @FXML private void handleButtonExitAction (ActionEvent event){ Stage stage=(Stage) buttonExit.getScene().getWindow(); //get the window that contains the exit button stage.close();//close it }
@Override public void initialize(URL url, ResourceBundle rb) {
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started