How To stop an Executed Jar file

前端 未结 9 1838
时光说笑
时光说笑 2021-02-03 23:20

It feels like a dumb question to ask, but i cant seem to figure it out. when i run a *.jar file on windows it doesnt apears in the taskmanager processes. how can i terminate it

相关标签:
9条回答
  • 2021-02-04 00:01

    On Linux

    ps -ef | grep java

    It will show u a list of processes out of which one will be your executable jar. Just kill that process by its process id.

    sudo kill -9 <pid>

    Is there any way to do this from the java code of the same jar file. Like killing itself once process completed.

    0 讨论(0)
  • 2021-02-04 00:06

    In windows task manager you will see process called "java.exe". Kill that process your application will get stop.

    To know the process first go to applications in task manager and then go to process by selecting that application. It will lead you to exact process of that application.

    Regards, Jaynil

    0 讨论(0)
  • 2021-02-04 00:10

    spring boot start/stop sample (on Windows OS).

    start.bat

    @ECHO OFF
    call run.bat start
    

    stop.bat:

    @ECHO OFF
    call run.bat stop
    

    run.bat

    @ECHO OFF
    IF "%1"=="start" (
        ECHO start your app name
        start "yourappname" java -jar -Dspring.profiles.active=prod yourappname-0.0.1.jar
    ) ELSE IF "%1"=="stop" (
        ECHO stop your app name
        TASKKILL /FI "WINDOWTITLE eq yourappname"
    ) ELSE (
        ECHO please, use "run.bat start" or "run.bat stop"
    )
    pause
    
    0 讨论(0)
  • 2021-02-04 00:15

    you could open jvisualvm to see the running java-processes. the process-id is displayed there. now open the task-manager go to the processes tab and add the process-id column to be displayed. now you can select the right java.exe or javaw.exe to kill

    0 讨论(0)
  • 2021-02-04 00:18

    As everyone stated it is either java or javaw process. The problem is when you're running multiple apps like that. One workaround might be naming the process differently as stated in:

    How can I set the process name for a Java-program?

    0 讨论(0)
  • 2021-02-04 00:20

    Find the process id by jps command & and kill them by taskkill command.

    Note that "-f" is required with taskkill or it may just sent a termination signal not actually terminating it.

    0 讨论(0)
提交回复
热议问题