简体   繁体   English

Java jar启动器仅用于控制台应用程序mac

[英]Java jar launcher for console only apps mac

I want to bundle my .jar app to automatically run open on mac os. 我想捆绑我的.jar应用程序,使其在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. 它没有GUI,因此需要从终端运行才能工作,但是我需要将其提供给不想使用终端的其他人。 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. 有关我的jar文件的更多信息:它是在netbeans中构建的,因此它确实具有通过ant构建jar所需的所有文件夹/ xml。 It needs a few additional libraries that are copied to the lib folder when netbeans builds the project. 它需要一些其他的库,这些库在netbeans生成项目时会复制到lib文件夹中。 Thirdly it needs to store temp files in a folder called assets that is located in the same folder as the jar file is. 第三,它需要将临时文件存储在一个名为资产的文件夹中,该文件夹与jar文件位于同一文件夹中。 I can change number 3 if need be. 如果需要,我可以更改3号。

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. 您的问题实际上与在Mac上运行没有太大关系-问题在于您正在尝试在没有控制台的情况下运行控制台应用程序。

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). 是在GUI窗口中提供控制台而不是在Shell(终端)中运行应用程序的一种方式的示例。

Once you have that working, you can consider wrapping it in the Mac - specific deployment that you pointed to. 工作完成后,您可以考虑将其包装在Mac(您指向的特定部署)中。

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 将您的类以及所有来自jar依赖项的类重新打包到一个大的“ uber-jar”中-有几种工具可以做到这一点,包括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. 将临时文件存储在系统的默认临时文件位置(使用File.createTempFile),而不是确切指定应将它们写入的位置。

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

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