0

I've a java program and executing on linux. Once my program execution completed it should come out of that program and should show the prompt. But it is not happening. I've used System.exit(0) also at the end of my main method. But still no luck. If i press enter then control coming out.The same program is working fine windows environment. I can't paste my code here,How to handle this.

Thanks, Aditya

Aditya
  • 115
  • 1
  • 9
  • 1
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [mcve] – CollinD Jul 27 '16 at 17:58
  • 1
    Possible duplicate of [linux script to kill java process](http://stackoverflow.com/questions/13711855/linux-script-to-kill-java-process) – Julian Jul 27 '16 at 17:58
  • You will need to debug your program to figure out why it is not terminating. It should terminate when all non-daemon threads have exited or after calling System.exit(). – BillRobertson42 Jul 27 '16 at 18:13
  • If you create threads, mark them as "daemon". Make sure that the end of main() is indeed reached (make sure you don't have infinite loop somewhere) –  Jul 27 '16 at 18:18
  • with the eclipse debug, i can see DestroyJavaVM thread is Running. It is causing the problem? – Aditya Jul 27 '16 at 18:55

1 Answers1

0

Got the root cause. I'm trying to execute my program via batch file, in that i've specified in the following command to execute.

CMD=""$JRE_BIN_PATH/java" $SP $TSSHDEBUG -cp $CP org.test.MainClass "$@""

if [ "$1" == 'run' ] && [ "$2" == 'server'] then $CMD &

I've added System.exit(0); in my code as well as i removed '&' in the command '$CMD &'

Aditya
  • 115
  • 1
  • 9