Search code examples
javamacosexecutable-jarautomator

run .jar on .app bundle with arguments


I created a .app bundle that executes jar file. I made the app bundle the default application for a specific file type. how to pass the selected file as argument to the java program

the script that I am using:

on run (input, parameters) 
  set p to POSIX path of (path to me) 
  do shell script java -jar" & p & "/Contents/Java/MyFile.jar' 
end run 

Solution

  • you can use "selection" to get the path of the selected file, and use POSIX to get the right representation:

    tell application "Finder"
        set filePath to POSIX path of (selection as text)
    end tell