SDNotify implements the systemd notification protocol in Java.
Switch branches/tags
Clone or download
Latest commit 7f17421 Apr 14, 2018
Failed to load latest commit information.
src remove dead code Apr 14, 2018
.gitignore import Feb 14, 2016
.travis.yml Rename travis.yml to .travis.yml Feb 15, 2016
LICENSE Create LICENSE Nov 15, 2016 Update Mar 6, 2018
pom.xml Update Dependencies Apr 10, 2018


SDNotify implements the systemd notification protocol in Java.

The Notify protocol uses datagram unix sockets, which are not accessible via Java; Therefore SDNotify includes a JNA wrapper of the socket API.

SDNotify is available via maven:


Basic usage

SDNotify is initialized at the first call to any send* function.

If the systemd environment isn't available, or the initialization fails a warning message is logged. All further calls to SDNotify are ignored.

import info.faljse.SDNotify.SDNotify;
public class SDTest {
    public static void main(String[] args) {
        SDNotify.sendNotify(); //notify: ready

Status text

systemctl status will print this string

SDNotify.sendStatus("No space left on device");

Watchdog, etc.

If a watchdog is configured systemd will kill the process when SDNotify.sendWatchdog() isn't called every n seconds. isWatchdogEnabled() and getWatchdogFrequency() may be used to determine if and at what interval sendWatchdog() should be called.

Also available: sendReloading(), sendStopping(), sendErrno(), sendBusError() , sendMainPID() - see sd_notify manpage for details.

Sample .service file

systemd service documentation

Description=My Java Server

ExecStart=/usr/bin/java -server -jar myserver.jar
# WatchdogSec=30
# Restart=always


Build Status