Managing Java Applications on Linux Systems

Running Java Applications in the Background

To execute a JAR file as a background process on Linux, utilize the nohup command combined with the ampersand symbol. This approach ensures the process continues running after terminal session termination.

nohup java -jar application-service.jar > runtime.log 2>&1 &
  • nohup: Maintains process execution after session tremination
  • java -jar application-service.jar: Executtes the speicfied JAR file
  • > runtime.log: Redirects standard output to log file
  • 2>&1: Merges standard error with standard output
  • &: Executes command in background mode

Monitoring Background Java Processes

To inspect currently running Java applications, employ process listing commands with appropriate filters:

ps aux | grep 'java.*jar'

For targeted process monitoring:

ps aux | grep 'specific-application.jar'
top -p [process-id]

Terminating Java Application Processes

To gracefully stop a running Java application:

  1. Identify the target process identifier:
ps -ef | grep target-application.jar
  1. Terminate using the acquired PID:
kill [process-id]
# For forced termination:
# kill -9 [process-id]

For automated process termination:

kill $(pgrep -f target-application.jar)
# Forceful alternative:
# pkill -f target-application.jar

Tags: Linux java JAR Process Management nohup

Posted on Thu, 16 Jul 2026 16:39:15 +0000 by kam_uoc