1

I have a JavaFX desktop application.

This app save data in "custom" files (".ppz"). In my app, I can browse in files and select the .ppz I want to open.

I've used javafx-maven-plugin and Inno Setup (with the .iss file) to create a .exe installer for Windows and file association. Everything work fine: the installer does his job, my app is running and I've create a file association who work (with a custom icon and everything).

But right now, when I double click on my ".ppz" file, my JavaFX app is just lunching. I would like to open the selected file (eg. : like clicking on a .doc is opening MS Word and the right file).

Any suggestions?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 3
    That sounds like an application issue more than an installer issue. Does your application handle the command line parameters passed when the .ppz file is double clicked? – mirtheil Oct 01 '18 at 22:13
  • Thank you for you answer @mirtheil =) Well, I've no idea. How can I check that? Should they be in the args[] of my main method? – Doc Fenster Oct 01 '18 at 22:46
  • 3
    Not sure how to do it using JavaFX. Here's a [link](https://stackoverflow.com/questions/36032888/using-command-line-arguments-in-java-with-javafx) that might get you started. Once you figure out how to accept the command line parameters, you'll need to figure out what to do with that information to open the file. – mirtheil Oct 01 '18 at 22:53
  • I believe you want to double click on the ppz file and have it open in your application, correct? If so, you need to expect the file path as an argument in the main method of your main class (like @mirtheil said), and also associate the file in your operating system. What are you using, Windows? – Fappaz Oct 02 '18 at 00:20
  • @FernandoPaz Yes, I'm using windows. I've tried to log args[] content in my main method, and it seems empty. I've also tried to use getParameters() in my start method, and it seems there are no args here neither. – Doc Fenster Oct 02 '18 at 09:23
  • How did you "tried" that? Did you attach a debugger to a process started by double-clicking an icon? – Martin Prikryl Oct 02 '18 at 09:38
  • I've logged the arg and yes, I've started by double-clicking a .ppz file. But I wasn't using the good method. getParameters().getNamed().toString() don't return me anaything, but .getUnnamed() or .getRow() return me the filename ! (cf. my answer bellow) – Doc Fenster Oct 02 '18 at 10:11

1 Answers1

4

Thanks to your comments I've found the solution.

Indeed, that wasn't an Inno Setup setting problem, everything was fine on this side and I just had to check the args within my app.

My first mistake was to check args the main method (instead of the start method). The second one was to use the wrong method for that.

Here is a sample who work for me :

public void start(Stage stage) {
    FXMLLoader loader = MyOwnLoader.getFxmlLoader();
    MyController controller = loader.getController();
    Parameters params = getParameters();
    log.error(params.getRaw().toString());
    //Also return the filename  : log.info(params.getUnnamed().toString());
    //Don't return the filename : log.info(params.getNamed().toString());
}

Now I just have to process the filename for opening it.

Thanks for you time and your comments.