Trying to run the following test.command script on Mac with a double-click. (requirement: MUST be run with a double-click)
#!/bin/sh
sudo java -jar ExecutableJar.jar
Here is the output. (The terminal stays open with the below message)
Last login: Mon Aug 13 15:59:05 on ttys001
/Applications/Application\ Folder/test.command ; exit;
code-mac:~ code$ /Applications/Application\ Folder/test.command ; exit;
Unable to access jarfile ExecutableJar.jar
logout
[Process completed]
When I run the same command from Terminal...
sudo java -jar ExecutableJar.jar
...it works fine and opens the executable jar as expected (after prompting for my password). Any ideas? Also, if possible, I'd like the script to either not open a terminal at all, or at the very least close the terminal after starting the executable jar.
Thanks!
ExecutableJar.jar. It's probably not in the default directory that double-clicked scripts get run in (probably your home directory). Running it manually, you have probably done acdbeforehand or something...test.commandscript to accommodate the users chosen installation location.dirnameon it? I'm not very familiar with the Mac/OSX environment. In that case,d=$(dirname $0)at the top of yourtest.commandand changing thejavainvocation tojava -jar ${d}/ExecutableJar.jarshould work. Won't work if you don't havedirname, though...