简体   繁体   English

在AppleScript中运行Java脚本

[英]Running a Java Script in AppleScript

Okay, so I'm trying to open a .jar file but no matter what I try, it always comes up with an error. 好的,所以我试图打开一个.jar文件,但是无论我尝试什么,它总是会出现错误。

I have tried: 我努力了:

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

With the error: 与错误:

error "Finder got an error: Can't get file \\"/Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar\\"." 错误“ Finder出现错误:无法获取文件\\“ / Applications / Technic Launcher.app/Contents/Resources/TechnicLauncher.jar \\”。 number -1728 from file "/Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar" 文件“ / Applications / Technic Launcher.app/Contents/Resources/TechnicLauncher.jar”中的编号-1728

And this: 和这个:

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

With the error: 与错误:

error "sh: /Applications/Technic Launcher.app/Contents/Resources/TechnicLauncher.jar: Permission denied" number 126 错误“ sh:/ Applications / Technic Launcher.app/Contents/Resources/TechnicLauncher.jar:权限被拒绝”编号126

I don't how I can make this work. 我不怎么做这项工作。 Can anyone help? 有人可以帮忙吗?

You can try this. 你可以试试看 I have not tried it on my system because I have no jar files I would like to open. 我没有在系统上尝试过它,因为我没有要打开的jar文件。 I think this will work for you though. 我认为这对您有用。

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

This should also work for you. 这也应该为您工作。

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

But the file TechnicLauncher.jar... Must be located inside the resources folder of the Script bundle or script application you have created. 但是文件TechnicLauncher.jar ...必须位于您创建的脚本包或脚本应用程序的resources文件夹内。

If you are just trying to launch it, given the jar is wrapped in a regular .app - have you tried 如果您只是尝试启动它,则将罐子包装在常规.app中-您是否尝试过

tell application "Technic Launcher"
    activate
end tell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM