Take the 2-minute tour ×

I'm running a java Code using the command java -jar Code.jar... I want now to terminate the program, how can I end the program using command line Linux?

share|improve this question

closed as not constructive by Luiggi Mendoza, J. Steen, Alex K, George Stocker Aug 24 '12 at 17:19


Kill <pid> using PID of your program. –  Rohan Aug 23 '12 at 17:29
Of course, this is not an advanced question, but the @downvoters should provide some explanation... –  home Aug 23 '12 at 17:30
the name of the code is Code.jar so I write Kill Code.jar?? –  user1475288 Aug 23 '12 at 17:30
are you on a *nix computer? –  squiguy Aug 23 '12 at 17:31
@Rohan you should post your comment as an answer –  squiguy Aug 23 '12 at 17:31
show 3 more comments

3 Answers

Usually pressing Ctrl+C will terminate the application.

You could also find the process ID for the process (use ps to see a list of running processes) and then kill the process using the kill command.

share|improve this answer
I can't use Ctrl-C because I run the program in different computer and now I want to terminate it –  user1475288 Aug 23 '12 at 17:30
@user1475288: You run the program in a different computer? What do you mean? –  Mark Byers Aug 23 '12 at 17:31
I run the program on my lab server on my lab computer and now I'm home so I need to terminate the Code or else :( –  user1475288 Aug 23 '12 at 17:33
@user1475288: Do you have shell access to the lab computer? –  Mark Byers Aug 23 '12 at 17:33
@user1475288 you should edit your question and explain the whole situation. Community people don't have a crystal ball to guess what exact problem you have. –  Luiggi Mendoza Aug 23 '12 at 17:38
show 2 more comments

You have a few different options some of which have been covered. Since you aren't at the machine in question you can't use ctrl+c obviously.

You could manually identify the pid with ps (ps -ef|grep ) and then kill it with the aformentioned kill

but I prefer pkill if it is available on the system. The pkill command will search the process tree for what you specify and kill that. It is similall to the killall command however pkill is grepping the processes extended attributes where killall only works on the process names. In this case your process is java but you probably don't want to kill all instances of java only the specific one so with pkill you can use the name of the jar file.

pkill Code.jar

share|improve this answer
add comment

You can try using Ctrl-C or just close the terminal ..

share|improve this answer
add comment
