简体   繁体   English

使用参数在.app捆绑软件上运行.jar

[英]run .jar on .app bundle with arguments

I created a .app bundle that executes jar file. 我创建了一个执行jar文件的.app捆绑包。 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 如何将所选文件作为参数传递给Java程序

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 

You OS should pass the file names as individual command line arguments. 您的操作系统应将文件名作为单独的命令行参数传递。 That means you get them as elements in the parameter of 这意味着您可以将它们作为元素作为参数

public void main(String[] args)

you can use "selection" to get the path of the selected file, and use POSIX to get the right representation: 您可以使用“选择”获得所选文件的路径,并使用POSIX获得正确的表示形式:

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

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

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