1

I'm in a situation where I need to use the SWT function Program.launch() but I also require to use it with arguments. Simply put: How can I achieve this? Is it even possible?

I have tried the "normal Mac way" of doing something like this:

Program.launch("/Applications/SomeApp.app --args myarg");

This was unsuccessful, and resulted in nothing happening (not even an error). I suspect this is because Program.launch() doesn't run through just a command line, but some other OS-specific method. Doing just Program.launch("/Applications/SomeApp.app"); works fine, but obviously lacks the arguments.

My situation is more explained in this question about Java .apps that can open other .apps. In there I explain how using open doesn't work, so I'm left with having to use alternatives, where Program.launch() seems like a good option.

So basically, is there a way to apply program arguments using Program.launch()?

Most similar topics I've read end up with the user migrating to another option, like open.

Magnus Bull
  • 1,027
  • 1
  • 10
  • 21

1 Answers1

2

Program.launch just accepts a file name or a URL.

Depending on the protocol of the URL there might be support for specifying arguments as part of the URL, the documentation of the URL format would tell you that.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I am able to use arguments with this through a URL protocol like `steam://`. But can the same be done for a local app? `file://` doesn't support it from what I've read. It runs the app but also ignores arguments. – Magnus Bull Apr 16 '16 at 17:21
  • `file` URLs don't support arguments. – greg-449 Apr 16 '16 at 17:29
  • So since it only accepts a file name (regarding local files), it cannot use arguments at all? I guess I will have to look for another method. – Magnus Bull Apr 16 '16 at 19:22