Runnable JAR已打开,但无效

时间:2017-05-19 17:48:22

标签: java eclipse intellij-idea javafx jar

所以,我制作了JavaFX项目,它在IDE中完美运行(由Eclipse和IntelliJIDEA检查),但导出的runnable jar不起作用(由Eclipse和IntelliJIDEA检查)。我无法想象,问题在哪里,因为我检查了导出并在2台计算机上运行此JAR。

@SuppressWarnings("unchecked")
@Override
public void start(Stage primaryStage) {
    try {
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("view.fxml"));
        layout = (AnchorPane) loader.load();
        Scene scene = new Scene(layout);
        primaryStage.setScene(scene);
        primaryStage.show();
        ff = (ImageView) scene.lookup("#FirstFrame");
        ff.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                if(pointCount < 4){
                    System.out.println(pointCount);
                    Point toAdd = new Point((int)event.getX(),(int)event.getY());
                    points.add(toAdd);
                    System.out.println(toAdd);
                    pointCount++;
                }
            }
       });
        @SuppressWarnings("rawtypes")
        ChoiceBox cb = (ChoiceBox) scene.lookup("#TrackerChooser");
        cb.setItems(FXCollections.observableArrayList(trackerList));
        cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>(){
            public void changed(@SuppressWarnings("rawtypes") ObservableValue ov, Number value, Number newValue){
                chosenTracker = trackerList[newValue.intValue()];
            }
        });
        Button start = (Button) scene.lookup("#Start");
        Button fileChooser = (Button) scene.lookup("#FileChooser");
        Button clear = (Button) scene.lookup("#Clear");
        ButtonController.clearListener(clear, this);
        ButtonController.startListener(start, this);
        ButtonController.fileChooserListener(fileChooser, scene, this);
    } catch(Exception e) {
        e.printStackTrace();
    }
}

public String getChosenTracker(){
    return chosenTracker;
}

public void setVideo(File v){
    video = v;
}

public void setPath(){
    path = video.getAbsolutePath();
}

public void setPreview() throws org.bytedeco.javacv.FrameGrabber.Exception{
    FFmpegFrameGrabber g = new FFmpegFrameGrabber(new File(path));
    g.start();
    Java2DFrameConverter jfc = new Java2DFrameConverter();
    Image im = SwingFXUtils.toFXImage(jfc.convert(g.grab()), null);
    ff.setImage(im);
    g.stop();
    System.out.println(im.getHeight() + " " + im.getWidth());
    System.out.println(ff.getFitHeight() + " " + ff.getFitWidth());
    System.out.println(ff.getY() + " " + ff.getX());
}

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

0 个答案:

没有答案