简体   繁体   English

向可运行的jar文件Mac OS添加参数

[英]Add arguments to runnable jar file Mac OS

I have created little java program with SWT. 我用SWT创建了一些Java程序。 For run it on Mac I need to use argument XstartOnFirstThread. 要在Mac上运行它,我需要使用参数XstartOnFirstThread。 So from terminal I can start it like 所以从终端我可以像这样开始

java -XstartOnFirstThread -jar progname.jar

Can I open this program using double click with this parameter? 是否可以双击该参数打开此程序? I know I may create script to run it, but is this possible without script? 我知道我可以创建脚本来运行它,但是如果没有脚本,这可能吗?

There is a related question here . 还有一个相关的问题在这里

The answer posted by Peter Lawrey states it outright: There is no way to pass the argument when starting the .jar by double-clicking. 彼得·劳里(Peter Lawrey)给出答案直接说明了这一点:双击启动.jar时,无法传递参数。

However, there are alternatives: 但是,还有其他选择:

  1. The double click starts a wrapper program which then starts your program with the parameter (as suggested in the linked answer). 双击启动包装程序,然后使用参数启动程序(如链接的答案中所建议)。
  2. Create a script file that launches your application. 创建一个脚本文件以启动您的应用程序。
  3. Create a proper OSX application instead . 而是创建一个合适的OSX应用程序

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

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