2017-08-21 87 views
0

好吧,所以我試圖打開一個.jar文件,但無論我嘗試什麼,它總是會出現錯誤。在AppleScript中運行Java腳本

我曾嘗試:

to run 

    set current_path to POSIX path of (path to me) as string 

    set pathto to current_path & "Contents/Resources/TechnicLauncher.jar" 

    tell application "Finder" to open file pathto 

end run 

與錯誤:

error "Finder got an error: Can’t get file \"/Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar\"." number -1728 from file "/Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar"

這:

to run 

    set current_path to POSIX path of (path to me) as string 

    set pathto to quoted form of current_path & "Contents/Resources/TechnicLauncher.jar" 

    do shell script pathto 

end run 

與錯誤:

error "sh: /Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar: Permission denied" number 126

我不怎麼做這個工作。誰能幫忙?

回答

-1

如果你只是想啓動它,因爲罐子被包裹在一個普通的.app - 你試過

tell application "Technic Launcher" 
    activate 
end tell 
0

你可以試試這個。我沒有在我的系統上嘗試過,因爲我沒有打開的jar文件。不過,我認爲這會對你有用。

set TechnicLauncher to (path to me as string) & "Contents:Resources:TechnicLauncher.jar" 
tell application "Jar Launcher" to open TechnicLauncher 

這也應該適合你。

set TechnicLauncher to path to resource "TechnicLauncher.jar" 
tell application "Jar Launcher" to open TechnicLauncher 

但文件TechnicLauncher.jar ......必須位於你所創建的腳本包或腳本的應用程序的資源文件夾內。