Open mfouka opened 6 years ago
You're supposed to use --args before your arguments.
Fairly certain you'll find that <app>/Contents/MacOS/<JavaAppLauncher or your custom named stub> <args>
works fine as well.
We Can change the name of the JavaAppLauncher script? We have to do something like that java -jar myapp.jar $ 1? or fill in the <args>?
JavaAppLauncher (the default name) is the app's stub executable that by default just runs the jar as if by java -jar whatever.jar
. In place of <args>
in your case would be file.txt
The full invocation would be myapp.app/Contents/MacOS/JavaAppLauncher file.txt
As for the executable name, the jar2app readme lists -e as an option.
-e EXECUTABLE, --executable-name=EXECUTABLE Name of the internal executable to launch (Default: JavaAppLauncher).
Thanks for your feedback, I regenerated my .app with a shell / bin / bash executable run.sh:
java -jar Contents/Java/myjar.jar $ 1
and I was pointing during the generation of my .app --executable-name = run.sh but when I run the executable nothing starts!
That's not what --executable-name is intended for. It's for being able to rename the standard JavaAppLauncher stub to whatever name you want the built app to use. If you were to name it run.sh, I'd imagine the name would be applied but wouldn't execute properly as having a shell script be the main executable of a .app bundle is... Odd.
Try building the app as you originally did but run it with open -n -a myapp.app --args file.txt
This should be the most straightforward way. Tell me if that doesn't work, my MacBook's in the shop so I can't really test this.
I tested with command open -n -a myapp.app --args file.txt , but it does not work!
What do you get in the terminal, and does the app launch
The application does not launch, no message on the console !
I tested on high sierra and it opens with the command open myapp.app --args file.txt (open without option) On the other hand when I open my file from the desktop and I double click (or open with myapp.app) my application starts but she still does not see the file do you have an idea ? Thank you
So.. You're saying open myapp.app --args file.txt
opens the app and it recognizes the passed argument?
If you want the app to automatically use the file like that whenever you double-click the app, shouldn't you just refactor that into your code as a constant File field somewhere and ignore the arguments? Alternatively, you could modify the built app to execute a script or create a script app.
Yes exactly I tested it on Sierre Height and El Capitan Thank You
Sorry. I assumed the stub recognizes arguments. It doesn't. Either you rely on making the jar launch through a shell script instead of bundling an app or hardcode the file name into your program. Doesn't seem possible to make arguments work here.
Heh. Added PR #34, which you should be able to use with the likes of universalJavaApplicationStub to get arguments working.
Once I used jar2app from that PR with -x universalJavaApplicationStub
(universalJavaApplicationStub downloaded from the repo linked above was in the same directory as the jar I packaged), I was able to get arguments working as expected.
I doubt that the PR will get merged any time soon (given both splash PRs have been idle for ages) so you can just download my fork's branch if you want.
Hi!
As you can tell, I don't at the moment have very much time to give the support I want to in any of my projects, but I've merged the pending PRs. Do you confirm they are working?
If you need anything else, do say, I'll try to find some free time between work and side-project work to fit in gratis-side-project work :)
Thank you for your developments!
Yes, I tested the user-provided stub PR with multiple cases on my programs (no customization, custom name only, custom stub only [name is kept to default JavaAppLauncher], custom name + custom stub [stub is copied with a new name). It works as you'd expect. Seriously, thanks for making this amazing project.
Great Work ! Thank You.
Is your issue resolved / do you want to close this issue?
I would like to pack a java application with script my script starts with java -jar myapp.jar file.txt to convert it to macos I converted my jar with your tools but the problem when I run open -n myapp.app file.txt the program does not see the arguments?