简体   繁体   English

将脚本/可执行文件放置在应用程序中的何处

[英]Where to put scripts/executables that will be called in the application

I have a vbscript that my Windows-only application uses. 我有一个仅Windows应用程序使用的vbscript。 I call it using Runtime exec 我使用Runtime exec称呼它

wscript my_script.vbs

And it works. 而且有效。

Now I want to distribute the application as a jar. 现在,我想将应用程序分发为jar。 Where should I put the script? 我应该把脚本放在哪里?

您可能想考虑一个名为resourcesscripts的文件夹,该文件夹与srcbin文件夹处于同一级别。

Include the file in your JAR. 将文件包含在您的JAR中。 The first time you need it, copy it from the JAR: 第一次需要它时,请从JAR中复制它:

this.getClass().getResourceAsStream("my_script.vbs");

And store it in the Application Data directory: 并将其存储在Application Data目录中:

File file = new File(System.getProperty("user.home") + "/Application Data/MyApp/my_script.vbs");

Run it as needed from there. 从那里根据需要运行它。

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

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