Skip to content
Markus Enax edited this page Mar 14, 2021 · 18 revisions

java-systemd

This Java library provides access to systemd via D-Bus. It features:

  • Simultaneous connectivity to the system bus and the session bus of the Java process owner
  • Access to the particular instance-wide 'Manager' interface, including
  • Method calls (ListUnits, StartUnit, StopUnit, RestartUnit, etc.)
  • Property access (Environment, SystemState, KernelTimestamp, etc.)
  • Convenience methods for instantiation of unit wrappers (see next bullet)
  • Access to methods and properties of the 'Unit' interface and all derived interfaces, like
  • Device
  • Mount
  • Service
  • Target
  • ...
  • Encapsulation of complex properties into objects with meaningful fields
  • Utility methods (timestamp conversion, path escaping, etc.)

Requirements

dbus-java is required for this library to work. It is available on the central repository.

Building

Maven is used as the primary build system. The code is based on OpenJDK 11.

Testing

Unit tests are based on TestNG and Mockito. Test methods which require a deployed systemd environment are grouped in TestNG group "requireSystemd". There are two TestNG suites available:

  • src/test/resources/suites/auto-systemd.xml (executes all tests)
  • src/test/resources/suites/auto.xml (excludes group "requireSystemd")

Use "auto.xml" for platform independent build systems.

License

LGPL v2 and AFL v3.0.

Clone this wiki locally