S
S
Sergo Zar2021-07-28 19:00:51
Java
Sergo Zar, 2021-07-28 19:00:51

Error Exception in Application start method?

I am trying to compile and run the program but I am getting the following error:

Exception in Application start method
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -3
        at java.base/java.util.Arrays.copyOfRange(Arrays.java:3781)
        at java.base/java.util.Arrays.copyOfRange(Arrays.java:3741)
        at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:427)
        at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192)
        at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)

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

public class test1 extends Application{
    @Override
    public void start(Stage primaryStage) throws Exception{
        // Parent panel = FXMLLoader.load(getClass().getResource("test1.fxml"));
        URL url = new URL("test1.fxml");
        Parent panel = FXMLLoader.load(url);
        // FXMLLoader panel = new FXMLLoader(url);
        Scene scene = new Scene(panel,300,300);

        primaryStage.setTitle("Test jfx");
        primaryStage.setScene(scene);
        primaryStage.show();

    }

    public static void main(String[] args){

        launch(args);
        // System.out.print(args);
    }
}

test1.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geomery.Insets?>
<?import javafx.scene.layout.GridPane?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.BorderPane?>

<!-- <GridPane fx:controller="sample.Controller" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"> -->
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">

<BorderPane>
    <top>
        <Label text="test javafx"/>
    </top>
    <center>
        <Button text="test"/>
    </center>
</BorderPane>


</GridPane>

I compile like this
javac -classpath "C:\\Program Files\\Oracle\\JavaFX 2.2 Runtime\\lib\\jfxrt.jar" test1.java

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question