将资源添加到系统路径
我有一个包括.bat文件的Maven应用程序,用于在Window的CLI中使用。
我正在考虑将.EXE导出(使用启动4J)请求管理员权限并将资源复制到程序文件中的子文件夹,还是我应该将它们移动到其他地方?如果是这样,我该如何将文件夹的/bin
路径添加到路径环境变量?
欲了解更多澄清,我想做与Java一起使用。
I have a Maven application that includes .bat files, for usage in Window's CLI.
I'm considering having my .exe export (using launch4j) to request admin permissions and copy the resources to a subfolder in Program Files, is this good practice or should I move them somewhere else? If it is, how could I add the folder's /bin
path to the PATH environmental variable?
For more clarification, I want to do this with java.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过Maven Exec插件?
您可以使用EXEC插件来执行任何命令,但具体来说,如果您想调用自己的Java程序,这是您的构建输出,则可以使用exec:java target。您可以直接提及应用程序的主要类,也可以为其提供VM参数,而不是执行JAR。
详细的文档为在这里
请注意,请注意您可以包括环境变量在Maven自己的环境属性访问方法的帮助下调用EXEC目标。
您可以使用此插件进行更多操作(使用配置创建不同的运行模式,从项目依赖项中运行服务器,将输出重定向到错误文件(重定向MVN输出本身)等等...插件文档,然后全部尝试。
Did you try the maven exec plugin?
You can potentially execute any command using the exec plugin but specifically if you want to invoke your own Java program which is the output of your build, you can use the exec:java target. Instead of executing your jar, you can directly mention the main class of your application and also furnish it with vm arguments.
Detailed documentation is here
Please note that you can include the environment variables while invokign the exec target with the help of maven's own environment property access methods.
There is a lot more you can do with this plugin (create different run-modes using the configurations, run servers from within your project dependencies, redirect output to an error file (redirect the mvn output itself) and so on... Read the plugin documentation and try them all out..