How can I write a startup script for Mac OS X?

谁说我不能喝 提交于 2019-12-21 16:58:56

问题


I have created a jar file in java, and I want to make the application automatically start during system boot up. I found I have to write a shell script for that. What should be that shell script look like? Is there anything else I have to do to make an application automatically start at boot up?


回答1:


The preferred way to launch programs at OS X startup is to create a launchd daemon as explained here.




回答2:


In mac os x you can also just run "open program.jar" (or any folder, '-a' for native applications) and it will open detached from the terminal with any default environment settings that it would use if you just double clicked it.

You can also add a program (or the script) to the user's login items through System Preferences > Accounts > 'username' > Login items. This is completely point and click and doesn't require a shell script




回答3:


The shellscript would be something like this:

cd /directory/to/jar
java -jar Jar.jar

Or maybe you don't actually need to write Jar.jar, only Jar. I don't quite remember.



来源:https://stackoverflow.com/questions/1857838/how-can-i-write-a-startup-script-for-mac-os-x

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