博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jps看不到进程号
阅读量:5860 次
发布时间:2019-06-19

本文共 7536 字,大约阅读时间需要 25 分钟。

之前电脑好好的,不知道为什么突然间用jps看不到进程号了,jconsole倒是可以的。

 

上网一搜,这方面的内容很少,一般出现问题都是在生产环境下linux机器上/tmp目录被定期清洗造成的。我想我以前也没弄过啊,不清楚为什么不可以。

 

但是不管怎么说,搜到了几篇有用的文章。

1、

2、

3、

 

 

JConsole local process list on Windows systems

Several times in the and SDN forums I have seen developers post questions like What should I see in the connection dialog's local process list in JConsole when running on Windows platforms?. There are several answers to this question depending on how both JConsole and the target Java application have been deployed, and more precisely, how the TMP and/or TEMP environment variables have been set in the command shell before launching them.

The following matrix should help you answer the question when JConsole and the target VM are running on JDK 6 or JDK 7:

JConsole/TargetVM matrix for local process list
JConsole ---------->
<---------- Target VM
TMP set to NTFS filesystem1 TMP set to FAT filesystem TMP not set TMP set to non-existing directory
TMP set to NTFS filesystem1 OK2
Java app name
OK2
pid@hostname
KO3 OK2
pid@hostname
TMP set to FAT filesystem KO3 OK2
pid@hostname
KO3 OK2
pid@hostname
TMP not set KO3 OK2
pid@hostname
OK2
Java app name
OK2
pid@hostname
TMP set to non-existing directory KO3 OK2
pid@hostname
KO3 OK2
pid@hostname
  1. NTFS filesystem or any filesystem that supports persistent access control lists.
  2. In the OK cases the output displayed by JConsole in the local process list is:
    • Java app name: the target application's main class name (or jar file if the application was started with the -jar option), or
    • pid@hostname: the process id and the name of the machine where the Java process is running. For example, "1234@oneserver".
  3. In the KO cases you don't see the target VM process in the local process list but you can still connect to it with JConsole by calling jconsole pid where pid can be looked up using the Windows Task Manager application.

NOTE: Sometimes even when both JConsole and the target VM have been started with the TMP and/or TEMP environment variables set to an NTFS filesystem you don't see the Java app name in the local process list. Usually this happens when the output from the jps command is empty and may be due to a file permissions problem. In such situations go to the directory that TMP is defined as and see if there is a directory named hsperfdata_user where user is your login. That is the directory where the instrumentation buffers are mapped (as shared memory files). Each time a java process starts it should create a file in that directory. The file name is the pid and that is how jps and the other jvmstat tools get the process list. If you don't see any pid-like files in the directory then it might be a permission problem. Try to create a file in the directory. If you get an "access denied" error then try to display and modify the ACLs of the directory with the cacls.exe command-line tool. If the problem still persists or you cannot change the ACLs of the directory then a workaround might be to create a new temporary directory in one of the NTFS partitions and just update the TMP variable in your environment to point to it. You can access the environment variables through Control Panel -> System -> Advanced -> Environment Variables.

« | | »

Comments:
Doesn't the TEMP/TMP environment variables set the java.io.tmpdir system property?

Posted by adobni on July 11, 2007 at 07:53 PM CEST

Yes, setting TMP/TEMP modifies the value of java.io.tmpdir.

When you set the TMP and TEMP environment variables to a given pathname then the java.io.tmpdir system property will point to the same pathname. However, when both the TMP and TEMP environment variables are unset the java.io.tmpdir system property will point to the "C:\\Documents and Settings\\user\\" directory.

NOTE: TMP always takes precedence on TEMP unless TMP is unset.

Posted by on July 12, 2007 at 09:10 AM CEST

Wow this was invaluable, thanks for posting it.

Posted by LK on December 13, 2007 at 01:29 AM CET

I googled for long time to notice the permission problem for hsperfdata_user.

Suggest to show this kind of error in console, it really can save a lot of efforts for others
>jps
#warning, can't have permission on "hsperfdata_user", please check

Posted by larry cai on January 07, 2008 at 02:07 AM CET

wow, the hsperfdata_user acl was a shock. My jconsole now displays the local pids just fine. thanks for sharing the info.

Posted by major banzai on January 26, 2008 at 12:21 AM CET

As mentioned in the first comment of if your windows username has uppercase chars, then it doesn't work.

The solution is to rename %TMP%\\hsperf_MyUser to %TMP%\\hsperf_myuser. And to do the rename you need to quit all java processes.

Posted by David Roussel on September 23, 2008 at 11:48 AM CEST

Actually, the rule for enabling jps and jconsole is - rename %TMP%\\hsperf_<user> to be exactly equal to your user name (including the case) and remove "Read-only" flag from it.

Windows XP SP 3, JDK 1.5.06

Posted by Dmitry Khalatov on January 04, 2009 at 02:56 PM CET

This is the SECOND time this page saves me (this time permission problems due to Active Directory upgrade). I deleted the hsperfdata directory and it was recreated with the correct permissions. Thanks again!

Posted by LK on January 22, 2009 at 06:41 PM CET

Still having the issue... I don't get it, it works on some machines, others it doesn't (win2003 64-bit) - 1.5.0_14_64bit - I checked the above, all is fine... I see the jconsole pid show in the dir, but NONE of the others... all the java processes are started with the

-Dcom.sun.management.jmxremote flag (even windiff'd to check that nothing odd was up)... made sure all env vars match (even used process explorer to compare that internally)... still no dice... ideas?

Posted by Steven May on April 01, 2009 at 10:24 PM CEST

Located some other items required to get this working (windows/64-bit) ... If using an RDP connection, you MUST used the /console connection to run jconsole under... also, due to that, it also requires elevated privs... the info about the file system privs above was also excellent, even though it wasn't my issue, it DID let me know that I had proper file perms, and could focus on another area... this thread by far was the most helpful of any I've seen. Now to the next step and trying to figure out how to get jconsole to run remotely from another machine - any helpful suggestions are welcome.

Posted by Steven May on April 04, 2009 at 06:39 PM CEST

Thanks a lot:

- hsperfdata_user explaination saved me with Windows XP use (upcased directory name)

In Linux environment, there is trouble for local process if the java process (mbean) is launched by a system service (with a specific group/owner) and jconsole launched with another account. They should have the same owner for correct working

Posted by SX Tang on October 16, 2009 at 09:34 AM CEST

My problem with JConsole on Windows was that the only process I could connect to was JConsole itself. Other java processes appeared in the list, but they were grayed out. The suggestion to rename the hsperfdata_<username> folder so that the case matched my username fixed this problem (i.e. hsperfdata_first.last -> hsperdata_First.Last). Note that the case of my username was not the same as the HOME directory that contained the hsperfdata folder (in C:\\Documents and Setttings\\first.last\\Local Settings\\Temp).

Posted by hal9000 on April 13, 2010 at 02:15 PM CEST

Deleted hsperfdata_%usr% and it is fixed. Thanks!

Posted by 206.169.227.195 on March 28, 2011 at 09:28 PM CEST

 

转载地址:http://umejx.baihongyu.com/

你可能感兴趣的文章
java ShutdownHook介绍与使用
查看>>
Eclipse的 window-->preferences里面没有Android选项
查看>>
《麦田里的守望者》--[美]杰罗姆·大卫·塞林格
查看>>
[置顶] 深入探析Java线程锁机制
查看>>
ORACLE 日期函数[转载]
查看>>
遇到的那些坑
查看>>
央行下属的上海资信网络金融征信系统(NFCS)签约机构数量突破800家
查看>>
[转] Lazy evaluation
查看>>
常用查找算法总结
查看>>
grep 零宽断言
查看>>
iOS Deep Linkin 和 Deferred Deep Linking
查看>>
如何定制一个下拉框
查看>>
安卓绿色联盟最强联名,超百家应用/企业共贺新春
查看>>
【跃迁之路】【730天】程序员高效学习方法论探索系列(实验阶段487-2019.2.20)...
查看>>
The Rise of Worse Is Better 论文-学习笔记
查看>>
使用 Docker 部署 Spring Boot项目
查看>>
【技术性】Search知识
查看>>
leetcode389.Find The Difference
查看>>
linux上ssh免密登录原理及实现
查看>>
gradle-学习笔记(2)-多项目构建
查看>>