10

How I can run Java application at system startup on Windows/Linux/MacOS?

Any implementation of JNA/JNI shall be welcome.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Rajeev
  • 4,571
  • 2
  • 22
  • 35
  • Isn't there any JNA/JNI implementation that actually works – Rajeev May 12 '11 at 11:29
  • JNA/JNI are not technologies to start processes at startup, they are used to call native code from a Java application. – Jean-Philippe Pellet May 12 '11 at 15:37
  • Yeah I know that but there are common libraries to access to similar functionality under different OSes... this is my first project in java I would like to learn if there are some. – Rajeev May 18 '11 at 06:56
  • Possible duplicate of [How to create a windows service from java app](https://stackoverflow.com/questions/68113/how-to-create-a-windows-service-from-java-app) – Vadzim Jan 27 '19 at 09:05
  • @Vadzim Given the scope of that question is about windows services, which restricts it to Windows, it is not a duplicate. – Mark Rotteveel Jan 28 '19 at 10:43
  • @MarkRotteveel, yes, but that question is more mature and many solutions there are multiplatform and applicable here too. – Vadzim Jan 28 '19 at 10:52

4 Answers4

4

Take a look at http://wrapper.tanukisoftware.org. It provides a wrapper for java applications to run under the various operating systems. You can use the community edition.

Pierre
  • 1,329
  • 2
  • 12
  • 21
  • Downloadable TanukiSoftware Java Service Wrapper 64-bit binaries for Windows: http://www.krenger.ch/blog/tag/java-service-wrapper/ – Vadzim Feb 26 '13 at 18:53
3

You can consider your application as a service under linux, and add a script that could start it under /etc/init.d (on most distributions, I think). You'll then have to make the needed links to the runlevel folders, to decide when to run your application. I think you can use chkconfig too

A basic example of script can be found here

I don't have most clues for the other two systems, however.

Agemen
  • 1,525
  • 9
  • 18
3

On windows you can use reg add Add the path of your application to hklm/software/microsoft/windows/current version/run To see more ,on command prompt type reg add /? Alternatively yo can use system call to add it from your application itself

bLuE
  • 41
  • 1
2

Take a look at http://yajsw.sourceforge.net/. It's free and compatible reimplementation of TanukiSoftware Java Service Wrapper featuring free 64-bit support.

There is also a comparison table for YAJSW, JSW, ACD and L4J.

Vadzim
  • 24,954
  • 11
  • 143
  • 151