由于有关stackmap框架的错误,无法运行我的JavaFX应用程序

时间:2016-12-23 02:12:25

标签: java javafx

我有一个简单的JavaFX程序,代码如下:

package myapp;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class MyApplication extends Application {

    @Override
    public void start(Stage primaryStage) {
        BorderPane p = new BorderPane();
        Text t = new Text("Hello FX");
        t.setFont(Font.font("Arial", 60));
        t.setEffect(new DropShadow(2, 3, 3, Color.RED));
        p.setCenter(t);


        Button button2 = new Button("Accept");
        p.setRight(button2);

        Label label1 = new Label("Name:");
        TextField textField = new TextField();
        HBox hb = new HBox();
        hb.getChildren().addAll(label1, textField);
        hb.setSpacing(10);
        p.setBottom(hb);

        primaryStage.setScene(new Scene(p));
        primaryStage.show();

    }

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

它在我的机器上运行完美。但是当我将它作为jar文件导出并将其复制到我的cowoker机器时,并使用命令java -jar <file_name>运行它。它无法正常运行并抛出异常,如下所示:

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files (x86)\
HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files (x86)\H
P\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.
lang.VerifyError: Expecting a stackmap frame at branch target 12
Exception Details:
  Location:
    javafx/application/Application.<init>()V @0: ldc
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 12a8 12aa 01b8 00b0 57a7 0004 572a b700
    0x0000010: 192a 01b5 001a b1
  Exception Handler Table:
    bci [0, 9] => handler: 12

        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithA
rgs$156(LauncherImpl.java:352)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(Platfor
mImpl.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(PlatformI
mpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatch
er.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.ja
va:191)
        at java.lang.Thread.run(Thread.java:745)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.NullPointerException
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Lau
ncherImpl.java:383)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImp
l.java:328)
        ... 5 more

任何人都可以帮我解决这个问题吗?真的很感激。

1 个答案:

答案 0 :(得分:0)

感谢@Johnny Mopp,我发现一个简单的解决方法是添加一个JVM参数-noverify以使我的应用程序运行。