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

5
  • 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: minimal reproducible example Commented Jul 27, 2016 at 17:58
  • 1
    Possible duplicate of linux script to kill java process Commented Jul 27, 2016 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(). Commented Jul 27, 2016 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) Commented Jul 27, 2016 at 18:18
  • with the eclipse debug, i can see DestroyJavaVM thread is Running. It is causing the problem? Commented Jul 27, 2016 at 18:55

1 Answer 1

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 &'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.