user10624599
user10624599

Reputation:

Command line argument javafx

I am trying to write a simple program to plot a line graph using javafx.

I have the following code:

public class Plot extends Application {
  public void start(Stage stage){

  }

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

I want to be able to pass a .csv file as a command line argument when running the program. And access the file from within:

 public void start(Stage stage){
 }

Upvotes: 1

Views: 371

Answers (1)

Samuel Philipp
Samuel Philipp

Reputation: 11050

You can use the getParameters() method from the Application class (docs).

public class MyApp extends Application {
    @Override
    public void start(Stage primaryStage) {
        // for example list all given parameters
        getParameters().getRaw().forEach(System.out::println);
        // ...
    }

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

Upvotes: 3

Related Questions