知道在 Windows 机器上要杀死哪个 java.exe 进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/62418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Knowing which java.exe process to kill on a windows machine
提问by Peter
When a java based application starts to misbehave on a windows machine, you want to be able to kill the process in the task manager if you can't quit the application normally. Most of the time, there's more than one java based application running on my machine. Is there a better way than just randomly killing java.exe processes in hope that you'll hit the correct application eventually?
当基于 Java 的应用程序在 Windows 机器上开始出现异常时,如果您无法正常退出应用程序,您希望能够在任务管理器中终止该进程。大多数时候,我的机器上运行着不止一个基于 Java 的应用程序。有没有比随机杀死 java.exe 进程更好的方法,希望您最终会命中正确的应用程序?
EDIT:Thank you to all the people who pointed me to Sysinternal's Process Explorer - Exactly what I'm looking for!
编辑:感谢所有将我指向 Sysinternal 的 Process Explorer 的人 - 正是我正在寻找的!
采纳答案by Ricardo Reyes
Download Sysinternal's Process Explorer. It's a task manager much more powerfull than Windows's own manager.
下载Sysinternal 的 Process Explorer。它是一个比 Windows 自己的管理器强大得多的任务管理器。
One of it's features is that you can see all the resources that each process is using (like registry keys, hard disk directories, named pipes, etc). So, browsing the resources that each java.exe process holds might help you determine wich one you want to kill. I usually find out by looking for the one that's using a certain log file directory.
它的功能之一是您可以看到每个进程正在使用的所有资源(如注册表项、硬盘目录、命名管道等)。因此,浏览每个 java.exe 进程拥有的资源可能会帮助您确定要杀死的资源。我通常通过查找使用某个日志文件目录的那个来找到。
回答by Raithlin
Have you tried using Process Explorer from SysInternals? It gives a much better idea of what is running within the process. Available free online here: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
您是否尝试过使用 SysInternals 的 Process Explorer?它可以更好地了解流程中正在运行的内容。可在此处免费在线获取:http: //technet.microsoft.com/en-us/sysinternals/bb896653.aspx
回答by Henry B
I'd suggest downloading Process Explorer from Sysinternals and looking at the different java.exe processes more closesly, that way you can get a better idea of which one to kill.
我建议从 Sysinternals 下载 Process Explorer 并更仔细地查看不同的 java.exe 进程,这样您就可以更好地了解要杀死哪个进程。
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
It's very intuitive and you can find the java.exe processes and right click and goto their properties, from there you can see their command line, time of creation, etc which can help you find the process you want to kill.
它非常直观,您可以找到 java.exe 进程并右键单击并转到它们的属性,从那里您可以看到它们的命令行、创建时间等,这可以帮助您找到要杀死的进程。
Hope it helps.
希望能帮助到你。
回答by user6837
Using ProcessExplorerand hovering over the Java process will show the command line.
使用ProcessExplorer并将鼠标悬停在 Java 进程上将显示命令行。
回答by snafu109
You could try opening Windows Task Manager, going to the Applications tab, right clicking the application and then selecting "Go To Process". This will automatically highlight the appropriate process in the Processes tab.
您可以尝试打开 Windows 任务管理器,转到“应用程序”选项卡,右键单击该应用程序,然后选择“转到进程”。这将在“进程”选项卡中自动突出显示适当的进程。
回答by Mikezx6r
If the application is not responding at all, then Process Explorer is a good option.
如果应用程序根本没有响应,那么 Process Explorer 是一个不错的选择。
If it's sort of responding, but not dying, sometimes bringing up task manager, and then moving another dialog over the java process will give you a clue. The java process that's taking up cpu cycles to redraw is the one you're looking for.
如果它有点响应,但没有死,有时会调出任务管理器,然后在 java 进程上移动另一个对话框会给你一个线索。占用 cpu 周期来重绘的 java 进程就是您正在寻找的进程。
回答by Mikezx6r
In case you're developing software: use a java-launcher. I used for a few of my application [Exe4j][http://www.ej-technologies.com/products/exe4j/overview.html]and it worked very well. When the application is started, it's listed as for example "myserverapp.exe" or "myapp" in the windows tasks manager. There are other lauchers too (don't known them by heart), few of them might be for free too.
如果您正在开发软件:使用 java-launcher。我用于我的一些应用程序 [Exe4j][ http://www.ej-technologies.com/products/exe4j/overview.html]并且效果很好。当应用程序启动时,它在 Windows 任务管理器中被列为例如“myserverapp.exe”或“myapp”。还有其他的lauchers(不知道他们),其中很少有免费的。
回答by Tom Hawtin - tackline
Using jps in the JDK will give you more information. More information is display with the -m, -l and -v options.
在 JDK 中使用 jps 将为您提供更多信息。使用 -m、-l 和 -v 选项显示更多信息。
回答by TREE
Rather than using a third party tool, you can also make a pretty good guess by looking at all the columns in task manager if you know roughly what the various java processes on your system are. From the Processes tab, use View-> Select Columns and add PID, CPU Time, VM Size, and Thread count. Knowing roughly what the process is doing should help narrow it down.
如果您大致了解系统上的各种 java 进程是什么,那么您也可以通过查看任务管理器中的所有列来做出很好的猜测,而不是使用第三方工具。从“进程”选项卡中,使用“查看”->“选择列”并添加 PID、CPU 时间、VM 大小和线程数。大致了解流程正在做什么应该有助于缩小范围。
For example, in a client-server app, the server will likely use more memory, have more threads, and have used more CPU time because it has been running longer. If you're killing a process because it's stuck, it mightsimply be using more CPU right now.
例如,在客户端-服务器应用程序中,服务器可能会使用更多内存,拥有更多线程,并且因为运行时间更长而使用更多 CPU 时间。如果您因为进程卡住而终止进程,那么它现在可能只是在使用更多 CPU。
MAX java heap memory is usually directly reflected in VM Size. So if you're using -Xmx flags, the process with the larger setting will have a larger VM Size.
MAX java heap memory 通常直接反映在VM Size中。因此,如果您使用 -Xmx 标志,则具有较大设置的进程将具有较大的 VM 大小。
回答by Misha
Run jps -lv
which shows PIDs and command lines of all running Java processes.
Runjps -lv
显示所有正在运行的 Java 进程的 PID 和命令行。
Determine PID of the task you want to kill. Then use command:
确定要终止的任务的 PID。然后使用命令:
taskkill /PID <pid>
to kill the misbehaving process.
杀死行为不端的进程。