How to use Jar Launcher with specified jdk version
After long time efforts,I finally find the solution,that is ,to make your own Jar Launcher app:
-
Launch Automator to make Automator Quick Action
- Select Application
- Look for the Run Shell Script action with Filter Finder Items and add it to the right.
-
paste scripts here like this below:
I make some changes to make it better
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
cd "$(dirname "$@")"
java -jar "$@"
save this quick action as an app for example "open jar.app"
go to /System/Library/CoreServices/Jar Launcher.app/Contents/Resources and copy JarLauncher.icns
- cd to "open jar.app" you just made and paste JarLauncher.icns to "open jar.app/Contents/Resources"
- edit "open jar.app/Contents/Info.plist" and change key(AutomatorApplet to JarLauncher.icns):
<key>CFBundleIconFile</key>
<string>JarLauncher.icns</string>
- now you can choose to open with "open jar.app" just like before.