Restart4j
May 30, 2021 ยท View on GitHub
Library for restarting your JVM application. You will most likely use it for restarting your GUI application programmatically.
It works no matter how your application is running:
- From Jar
- From an IDE
- From a unique packaged form
- etc...
Requirements, Compatibility
- Java 8 or higher
- Works on the 3 major platforms: Windows, MacOS, Linux
Installation
Maven example
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Dansoftowner</groupId>
<artifactId>Restart4j</artifactId>
<version>1.4.7</version>
</dependency>
Gradle example
repositories {
...
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.Dansoftowner:Restart4j:1.4.7'
}
Some code examples
Simple restart
final ApplicationRestart appRestart = ApplicationRestart.builder().build();
appRestart.restartApp();
Restart with more options
final ApplicationRestart appRestart = ApplicationRestart.builder()
.beforeNewProcessCreated(() -> System.out.println("New process will be created..."))
.beforeCurrentProcessTerminated(() -> System.out.println("The app will be terminated"))
.build();
appRestart.restartApp();
Demo applications
Two demo applications can be found in the project:

Projects using Restart4j
If this library is used by your project, let me know in the Discussions and I will mention that in this section.
- Document Archiver - Archive all your documents in a consistent way, which enables you to retrieve them later fast and easy.
Used libraries
- SLF4j - Simple Logging Facade for java
- OSHI - Operating System & Hardware information
- Jetbrains annotations - Annotations for JVM-based languages