Java jar launcher for console only apps mac

泄露秘密 提交于 2019-12-13 03:39:47

问题


I want to bundle my .jar app to automatically run open on mac os. It has no GUI so it needs to be run from terminal to work but I need to give it to others who would rather not use terminal. How would I go about doing this? I tried the app builder that is seen here but it only shows up on activity monitor for a fraction of a second before going away. More info about my jar file: It was build in netbeans so it does have all the folders/xml needed to build a jar via ant. It needs a few additional libraries that are copied to the lib folder when netbeans builds the project. Thirdly it needs to store temp files in a folder called assets that is located in the same folder as the jar file is. I can change number 3 if need be.


回答1:


Your issue doesn't really have much to do with running on the mac - the problem is that you're trying to run a console app without a console.

Here is an example of one way to provide a console in a GUI window, rather than running the app in an shell (the terminal).

Once you have that working, you can consider wrapping it in the Mac - specific deployment that you pointed to.

For portability's sake, you may also want to consider:

  • Re-packaging your classes and all of the classes from your jar dependencies into one big "uber-jar" - there are several tools for doing this, including the Maven Assembly Plugin

  • Storing your temporary files in the system's default temp file location (using File.createTempFile) instead of specifying exactly where they should be written.



来源:https://stackoverflow.com/questions/14228873/java-jar-launcher-for-console-only-apps-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!