尝试在终端上执行jar文件后显示错误

时间:2019-07-10 00:33:56

标签: java terminal jar

当我试图通过终端执行它时,我创建的.jar文件似乎没有运行

我选择Jar作为Runnable JAR FILE export,文件名为grades.jar,这是执行我创建的GUI应用程序的前提。另外,我选择的Launch configuration:包含主要

   package GUI.project;

   public class GradeAnalyzer extends Application {
   private HBox hBox;
   private Button yesButton,noButton;
   private BorderPane bp, bp2;
   ScoreList scoreList = new ScoreList(100);
   @Override
   public void start(Stage stage) throws Exception {

      GradeError_window error = new GradeError_window();
      GUImain screen = new GUImain();

      hBox = new HBox();
      hBox.setTranslateX(40);
      hBox.setTranslateY(10);

      bp  = new BorderPane();
      bp2 = new BorderPane();

      yesButton = new Button("yes");
      noButton = new Button("no");

      yesButton.setMinWidth(50); //set width of the buttons
      noButton.setMinWidth(50);
      noButton.setTranslateX(20);

      yesButton.setOnAction((e)->
      {
            FileChooser chooseFile = new FileChooser();

           chooseFile.setTitle("Slecet .txt file");
           FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");

        chooseFile.getExtensionFilters().add(extFilter);
        File file = chooseFile.showOpenDialog(stage);

        try {
            Scanner scan = new Scanner(file);
            while(scan.hasNext() && scan.hasNextDouble())
            {
                scoreList.add(Double.parseDouble(scan.nextLine()));
            }

            if(scoreList.getList().isEmpty()) { //This will open a new window if the file selected doesn't contain numbers
                try {
                    error.start(stage);

                } catch (Exception e1) {
                    e1.printStackTrace();
                }                   
            }
            else {
                screen.start(stage, scoreList.getList(), scoreList);
            }

        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }

    });

    noButton.setOnAction(e->{
        screen.start(stage, scoreList.getList(), scoreList);
    });

    Label label = new Label("Would you like to load a file?");

    hBox.getChildren().addAll(yesButton,noButton);

    bp2.setCenter(label);
    bp.setTop(bp2);
    bp.setCenter(hBox);

    stage.setTitle("Grade Analyser");
    Scene scene = new Scene(bp);
    stage.setScene(scene);
    stage.setWidth(200);
    stage.setHeight(90);
    stage.show();

    stage.setMinWidth(stage.getWidth());
    stage.setMinHeight(stage.getHeight());
}

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

}

我希望程序能够在终端上运行,但其说法

  

错误:找不到或加载主类GUI.project.GradeAnalyzer

0 个答案:

没有答案