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 shel开发者_Go百科l 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?
The preferred way to launch programs at OS X startup is to create a launchd
daemon as explained here.
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
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.
精彩评论