Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Conversation

@dbankieris
Copy link
Contributor

Currently, you cannot pass command line arguments to the bundled application. For instance:
open MyJavaApp.app --args arg1 arg2
arg1 and arg2 are available in the universalJavaApplicationStub script, but it doesn't forward them in the call to java.
This commit just tacks a $@ on the end of the call to exec "$JAVACMD"

Currently, you cannot pass command line arguments to the bundled application. For instance:
open MyJavaApp.app --args arg1 arg2
arg1 and arg2 are available in the universalJavaApplicationStub script, but it doesn't forward them in the call to java.
This commit just tacks a $@ on the end of the call to exec "$JAVACMD"
…xist

Turns out that last commit broke no-argument applications, but only when launched via open. Calling the universalJavaApplicationStub script directly worked fine with or without arguments. Weird. I have no bash scripting experience, so if there's a prettier solution, please fix my fix!
@tofi86
Copy link
Owner

tofi86 commented Jun 25, 2016

Thanks for your contribution.

I haven't tested your PR yet, but it looks like the code is missing the exec command after your second commit... Did you do proper testing?

@tofi86 tofi86 self-assigned this Jun 25, 2016
…f they exist"

This reverts commit 4105979.

It turns out "open" sometimes passes a "process serial number" argument of the form -psn_X_YYYYYYY to apps when launching them. What little documentation I could find suggests the behavior differs across OS versions and whether or not the app is already open, so it's probably best not to worry about it in universalJavaApplicationStub and let the application handle it if present. Also, use "$@" instead of $@ to preserve argument whitespace.

For my app, on MacOS 10.10.5, the extra argument appears to be passed only if open is used without the --args option. My app terminates with a help message when such an unexpected argument is received, but open redirects the output to somewhere I can't find, so the observed behavior was silent termination after the splash screen.
@dbankieris
Copy link
Contributor Author

You are correct. Sorry about that. I hadn't actually cloned the repo, just copied the file, onto my machine. So I was editing it locally and then reflecting the changes directly on GitHub via it's editor. Poor form, obviously. I have since cloned it to my machine and pushed the latest commit from there.

@albertus82
Copy link

I'm interested in this topic, because I wrote an application that accepts an argument, i.e. a file to open. Now I wonder how the "Open with..." feature works in OS X and if it can be replicated for our java apps (I'm not a OS X expert, sorry). Thanks.

@tofi86
Copy link
Owner

tofi86 commented Oct 11, 2016

@albertus82 The "Open with…" feature works with registering a specific file extension in your Plist file like for example:

Jarbundler Ant task:

<jarbundler
        name="EPUB-Checker"
        …
        jvmversion="1.7+">

        <documenttype
            name="EPUB files"
            extensions="epub EPUB"
            role="Viewer"
        />

        …

</jarbundler>

(generated) Plist snippet:

<plist version="1.0">
  <dict>
    <key>CFBundleDocumentTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeName</key>
        <string>EPUB files</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleTypeExtensions</key>
        <array>
          <string>epub</string>
          <string>EPUB</string>
        </array>
      </dict>
    </array>
    …
  </dict>
</plist>

@tofi86 tofi86 changed the base branch from master to develop October 11, 2016 16:57
@tofi86 tofi86 added this to the Version 1.1 milestone Oct 11, 2016
@tofi86 tofi86 merged commit ae1048a into tofi86:develop Oct 11, 2016
@tofi86
Copy link
Owner

tofi86 commented Oct 11, 2016

Thanks for your contribution, @dbankieris!
This will 🚢 with version 1.1 (released anytime soon)…

tofi86 added a commit that referenced this pull request Oct 11, 2016
@tofi86
Copy link
Owner

tofi86 commented Nov 20, 2016

This was added in version 2.0.0 released just today! Thanks for your contribution! 👏

@albertus82
Copy link

Hi @tofi86, I upgraded to v2.0.0 but my application won't start anymore :( If I manually open the app folder and start universalJavaApplicationStub, then the app starts along with the terminal window. OS X El Capitan, italian language.

@tofi86
Copy link
Owner

tofi86 commented Nov 20, 2016

Opening a new issue for that, @albertus82. See #39

@tofi86
Copy link
Owner

tofi86 commented Nov 21, 2016

There was a regression in this PR which lead to the bug reported by @albertus82 in #39.
This should be fixed with 2.0.1 to be released soon...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants