简体   繁体   English

应用程序启动方法 java.lang.reflect.InvocationTargetException 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 中的异常

[英]Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I am having trouble finding what to fix in my fxml/java code, this is the whole error:我无法在我的 fxml/java 代码中找到要修复的内容,这是整个错误:

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(L 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) 在 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) 在 com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl. java:328) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang .reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) 原因:java.lang.RuntimeException:com.sun.javafx 的应用程序启动方法中的异常.application.LauncherImpl.launchApplication1(L auncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:748) Caused by: javafx.fxml.LoadException: No controller specified. auncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:748) 原因:javafx.fxml。 LoadException:未指定控制器。 /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml:23 at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597) at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103) at javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557) at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599) at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770) at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532) 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 IceCreamRUN.start(IceCreamRUN.java:11) at com.sun.java /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml:23 在 javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597) 在 javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103) 在 javafx.fxml。 FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557) 在 javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599) 在 javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770) 在 javafx.fxml .FXMLLoader.processEndElement(FXMLLoader.java:2823) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) 在 javafx.fxml.FXMLLoader.loadImpl( FXMLLoader.java:3214) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) ) 在 javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) 在 javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) 在 IceCreamRUN.start(IceCreamRUN.java:11) 在 com.sun.java fx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) fx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863) 在 com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326) 在 com.sun.javafx.application.PlatformImpl。在 com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) 在 com.sun.java.security.AccessController.doPrivileged(Native Method) 的 lambda$null$172(PlatformImpl.java:295)。 glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

I have been looking throught the 'RUN' and 'Control' code to try anf find the mistake and im not finding anything.These are the code for the 'RUN' program and the 'Control'我一直在查看“RUN”和“Control”代码以尝试找到错误,但我没有找到任何东西。这些是“RUN”程序和“Control”的代码

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class IceCreamRUN extends Application
 {
  public void start (Stage stage ) throws Exception
   {
  Parent parent = 
  FXMLLoader.load(getClass().getResource("IceCreamScene.fxml"));
  Scene scene = new Scene(parent);
  stage.setTitle("Patino's Ice Cream Shop");
  stage.setScene(scene);
  stage.show();

   }
  public static void main(String [] args)
   {
  launch(args);
   }
}

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import java.io.*;
import java.util.Scanner;

 public class IceCreamControl {

//declarations

@FXML
private RadioButton Vanilla;

@FXML
private ToggleGroup FlavorGroup;

@FXML
private RadioButton Choc;

@FXML
private RadioButton StrwBerry;

@FXML
private Button Save;

@FXML
private Button ReDo;

@FXML
private Button Calculate;

@FXML
private CheckBox Nuts;

@FXML
private CheckBox Cherries;

double creamcost = 0.0;
double extra = 0.0;

//processing

@FXML
void CalculateListener() 
{
      double sub, tax, total;
      double taxRate = 0.06;

      sub = VanillaListener() + ChocolateListener() + 
                StrawberryListener() 
                   + ExtraListener();
      tax = sub * taxRate;
      total = sub + tax;

      Alert alert = new Alert (AlertType.INFORMATION);
      alert.setHeaderText(String.format("Total: $ %.2f", total));
      alert.setContentText(String.format("Order: $ %.2f\nTax: %.2f\n 
      Total: $ %.2f", sub, tax, total));
      alert.setTitle("Your Order");
      alert.showAndWait();
  }

@FXML
double ExtraListener() 
{
      extra = 0.0;
      if(Cherries.isSelected())
         extra += 0.50;
      if(Nuts.isSelected())
         extra += 0.50;

      return extra;
}

@FXML
void ReDoListener() throws IOException 
{
   String order;
   creamcost = 0.0;
   extra = 0.0;
   Nuts.setSelected(false);
   Cherries.setSelected(false);
   Vanilla.setSelected(false);
   Choc.setSelected(false);
   StrwBerry.setSelected(false);

   File file = new File ("IcecreamSave.txt");
   Scanner inputFile = new Scanner (file);

   while(inputFile.hasNext())
      {
         order = inputFile.nextLine();
         if (order.charAt(0) == 'v')
            {
               Vanilla.setSelected(true);
               creamcost = 2.25;
            }
         if (order.charAt(0) == 'c')
            {
               Choc.setSelected(true);
               creamcost = 2.25;
            }
         if (order.charAt(0) == 's')
            {
               StrwBerry.setSelected(true);
               creamcost = 2.25;
            }
      }
   inputFile.close();
}

@FXML
void SaveListener() throws IOException 
{
PrintWriter outputfile = new PrintWriter ("IcecreamSave.txt");

if(Vanilla.isSelected())
  outputfile.println("vanilla"); 
if(Choc.isSelected())
  outputfile.println("chocolate");
if(StrwBerry.isSelected())
  outputfile.println("strawberry");
if (Nuts.isSelected())
  outputfile.println("nuts");
if(Cherries.isSelected())
  outputfile.println("cherry");

outputfile.close();
}

@FXML
double StrawberryListener() 
{
if (StrwBerry.isSelected())
    creamcost = 2.25;
   else creamcost = 0.0;
  return creamcost;
}

@FXML
double VanillaListener() 
{
if (Vanilla.isSelected())
    creamcost = 2.25;
   else creamcost = 0.0;
  return creamcost;
}

@FXML
double ChocolateListener() 
{
if (Choc.isSelected())
    creamcost = 2.25;
   else creamcost = 0.0;
  return creamcost;
   }

}

I would appreciate help finding the mistake immensely.我将非常感谢帮助找到错误。




Update: I fixed the location but got a new error;更新:我修复了位置,但出现了新错误;

 > Aug 15, 2018 1:28:21 PM javafx.fxml.FXMLLoader$ValueElement 
 processValue
 WARNING: Loading FXML document with JavaFX API of version 10.0.1 by 
 JavaFX runtime of version 8.0.171
 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(DelegatingMethodAccessorImp l.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherI mpl.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$154(LauncherImpl. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com。 sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherI mpl.java:389) 在 com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 sun.launcher。 LauncherHelper$FXHelper.main(LauncherHelper.java:767) 原因:java.lang.RuntimeException: com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) 在 com.sun 的应用程序启动方法中的异常。 javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl. java:182) at java.lang.Thread.run(Thread.java:748) Caused by: javafx.fxml.LoadException: No controller specified. java:182) at java.lang.Thread.run(Thread.java:748) 原因:javafx.fxml.LoadException:未指定控制器。 /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml:22 /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml:22

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557)
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
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 IceCreamRUN.start(IceCreamRUN.java:11)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

Exception running application IceCreamRUN异常运行应用程序 IceCreamRUN

The reason is in the root cause exception.原因在于根本原因异常。 It cannot find the IceCreamScene.fxml .它找不到IceCreamScene.fxml Check, that the file exists in proper location.检查文件是否存在于正确的位置。

Your app is looking for it in this path: /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml您的应用正在以下路径中寻找它: /Volumes/OSTIUM/Labs/CAPSTONE/IceCreamScene.fxml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaFX:应用程序启动方法中的异常 java.lang.reflect.InvocationTargetException - JavaFX: Exception in Application Start Method java.lang.reflect.InvocationTargetException 应用程序启动方法 java.lang.reflect.InvocationTargetException 中的异常 - Exception in Application start method java.lang.reflect.InvocationTargetException 应用程序启动方法java.lang.reflect.InvocationTargetException中的异常[NO FXML] - Exception in Application start method java.lang.reflect.InvocationTargetException [NO FXML] exception java.lang.IllegalArgumentException:object不是在sun.reflect.NativeMethodAccessorImpl.invoke0声明类的实例 - exception java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0 应用程序启动方法 java.lang.reflect.InvocationTargetException 中的 JavaFX 异常问题 - Problem with JavaFX Exception in Application start method java.lang.reflect.InvocationTargetException 应用程序启动方法java.lang.reflect.InvocationTargetException Javafx fxml中的异常 - Exception in Application start method java.lang.reflect.InvocationTargetException Javafx fxml 应用程序启动方法java.lang.reflect.InvocationTargetException中的异常JavaFX图像过渡 - Exception in Application start method java.lang.reflect.InvocationTargetException JavaFX image transition 在 Java 中收到错误并且不明白问题:Application init method java.lang.reflect.InvocationTargetException 中的异常 - Receiving an error in Java and don't understand the problem: Exception in Application init method java.lang.reflect.InvocationTargetException 应用程序构造函数java.lang.reflect.InvocationTargetException中的JavaFX异常 - JavaFX Exception in Application constructor java.lang.reflect.InvocationTargetException javafx中的java.lang.reflect.InvocationTargetException中的异常 - Exception in java.lang.reflect.InvocationTargetException in javafx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM