Reputation: 7376
I write a java program which is run in the background. And it works fine,it does what is waited from it.
I write a bat
file in windows to run it.
@echo off
start .\jre7\bin\java.exe -jar ".\my_jar.jar"
exit
When I run this .bat
file I can see it on task manager and It works and when it finished , the java.exe process is closed on the task manager.
It works fin on Windows
But When I run it on linux in .sh file,
It the java program works fine because It does what I wait from it ,but on the Sytem Monitor
the java process is not closing. I want it to close by itself like Windows.
in sh file:
export JAVA_HOME="/app/myfolder/java/jre1.7.0_51"
export I_HOME="/app/myfolder/code"
cd $I_HOME
$JAVA_HOME/bin/java -jar my_jar.jar
RStat=$?
What is the problem?
Upvotes: 0
Views: 2920
Reputation: 2012
Its definitely not normal for it to terminate gracefully on windows and not on linux. Your jar could just be hanging on linux due to differences in whatever native libraries you're using, have you tried calling System.exit()?
Upvotes: 1
Reputation: 8068
Have you set your thread to a daemon?
public final void setDaemon(boolean on)
From the JavaDoc:
Marks this thread as either a daemon thread or a user thread. The Java Virtual Machine exits when the only threads running are all daemon threads
Upvotes: 0