<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6406593750327945950.post2447797443819124233..comments</id><updated>2011-10-03T06:50:49.741-07:00</updated><category term='DotSunEngineering'/><category term='Software Engineering'/><category term='SunWikis'/><category term='Rails'/><category term='Zoom23'/><category term='MacOS'/><category term='MacBook Pro'/><category term='Gadgets'/><category term='Security'/><category term='Fun'/><category term='Apple'/><category term='Java'/><category term='JavaOne2007'/><category term='JavaFX'/><category term='OpenSolaris'/><category term='Life'/><category term='Sun'/><category term='JRuby'/><category term='Slovakia'/><category term='Ruby'/><category term='Apps'/><category term='Other Ramblings'/><category term='Projects'/><category term='Apple Problems'/><category term='Solaris'/><category term='grizzly-sendfile'/><category term='Glassfish'/><category term='Mediacast'/><title type='text'>Comments on Igor Minar's Blog: How a Java Application Can Discover its Process ID...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.igorminar.com/feeds/2447797443819124233/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default?start-index=26&amp;max-results=25'/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5718603363956015560</id><published>2011-10-01T15:59:01.768-07:00</published><updated>2011-10-01T15:59:01.768-07:00</updated><title type='text'>I found a (hackish and fun) way using the JVM atta...</title><content type='html'>I found a (hackish and fun) way using the JVM attach API, you can read more about it there : https://github.com/vietj/PID</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5718603363956015560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5718603363956015560'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1317509941768#c5718603363956015560' title=''/><author><name>Julien Viet</name><uri>http://www.blogger.com/profile/04710381063905327936</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2018556437'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5220402814324303134</id><published>2011-09-05T06:42:47.126-07:00</published><updated>2011-09-05T06:42:47.126-07:00</updated><title type='text'>The latest I discovered is the system property sun...</title><content type='html'>The latest I discovered is the system property sun.java.launcher.pid which is set on at least linux platforms JDKs.  I haven&amp;#39;t tried other Unix.  It is not set on Windows.  I was going to query that system property and if it isn&amp;#39;t set go to the defacto of looking at the JMX Bean.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5220402814324303134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5220402814324303134'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1315230167126#c5220402814324303134' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-832178212'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5928472629525766491</id><published>2011-06-28T20:16:31.031-07:00</published><updated>2011-06-28T20:16:31.031-07:00</updated><title type='text'>The 6th way is useless unless you know the pid bef...</title><content type='html'>The 6th way is useless unless you know the pid before you run it which brings us full circle. jvisualvm uses the RuntimeMXBean.getName() method to find a list of vms to attach to and it must parse the pid out of those names. This seems to be the defacto standard.&lt;br /&gt;By the way, All machines have a pid for each process. Otherwise they couldn&amp;#39;t track processes at all. The difference is whether they expose them.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5928472629525766491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5928472629525766491'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1309317391031#c5928472629525766491' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-515973646'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-6524215335624437601</id><published>2010-11-17T04:00:21.061-08:00</published><updated>2010-11-17T04:00:21.061-08:00</updated><title type='text'>Hi, another useful approach may be by using JNA(Ja...</title><content type='html'>Hi, another useful approach may be by using JNA(Java Native Access) library (https://jna.dev.java.net/)&lt;br /&gt;&lt;br /&gt;It is, however platform dependent. If you work under M$ all code is:&lt;br /&gt;&lt;br /&gt;Kernel32.INSTANCE.GetCurrentProcessId();&lt;br /&gt;&lt;br /&gt;If you work under UNIX, the code will be different and not as simple, but JNA allows you to use native libraries quite easily under most OS.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6524215335624437601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6524215335624437601'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1289995221061#c6524215335624437601' title=''/><author><name>Pawel</name><uri>http://www.blogger.com/profile/04733595907944666028</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1750832803'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-4418705670800985384</id><published>2010-05-16T03:46:08.599-07:00</published><updated>2010-05-16T03:46:08.599-07:00</updated><title type='text'>Excellent find Laurent. Thanks for sharing.</title><content type='html'>Excellent find Laurent. Thanks for sharing.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4418705670800985384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4418705670800985384'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1274006768599#c4418705670800985384' title=''/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1473152891'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-1278305812854151124</id><published>2010-05-15T05:02:39.297-07:00</published><updated>2010-05-15T05:02:39.297-07:00</updated><title type='text'>Hi Igor,

I think I&amp;#39;ve found a 6^th way. It&amp;#3...</title><content type='html'>Hi Igor,&lt;br /&gt;&lt;br /&gt;I think I&amp;#39;ve found a 6^th way. It&amp;#39;s based on the Attach API that didn&amp;#39;t exist at the time you posted this entry. &amp;quot;Attach API&amp;quot;&lt;br /&gt;http://blogs.sun.com/CoreJavaTechTips/entry/the_attach_api &lt;br /&gt;is like a Java API to list Java processes like JPS does. In addition, one may attach to JVMs, query for system properties and load Java agents. The ``VirtualMachineDescriptor`` really looks like a String-based PID. By now it&amp;#39;s a Sun (mean: Oracle) specific API. This doesn&amp;#39;t mean other JVM don&amp;#39;t support it.&lt;br /&gt;&lt;br /&gt;That&amp;#39;s extremely cool stuff when it comes to kill JVMs spawned with ``ProcessBuilder``. After tagging them with a special system property, you can shut them down gently by loading an agent that calls ``System.exit``. At least it&amp;#39;s supposed to be cross-platform (disclaimer: I didn&amp;#39;t try it for now).&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;&lt;br /&gt;Laurent Caillette&lt;br /&gt;&lt;br /&gt;Mail written in Novelang</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1278305812854151124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1278305812854151124'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1273924959297#c1278305812854151124' title=''/><author><name>Laurent Caillette</name><uri>http://novelang.sf.net</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-210398497'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-7959244969264861906</id><published>2010-05-11T03:13:54.542-07:00</published><updated>2010-05-11T03:13:54.542-07:00</updated><title type='text'>Cool Brett, I&amp;#39;m glad that it was useful. Too b...</title><content type='html'>Cool Brett, I&amp;#39;m glad that it was useful. Too bad that even after 3 years, there is no hint from Sun/Oracle that we&amp;#39;ll ever get a proper api to do this.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/7959244969264861906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/7959244969264861906'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1273572834542#c7959244969264861906' title=''/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1473152891'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-2472365566103396092</id><published>2010-05-10T16:31:57.564-07:00</published><updated>2010-05-10T16:31:57.564-07:00</updated><title type='text'>nice summary Igor. 

I&amp;#39;m using glassfish v3 an...</title><content type='html'>nice summary Igor. &lt;br /&gt;&lt;br /&gt;I&amp;#39;m using glassfish v3 and really wanted the java process to write its pid.&lt;br /&gt;&lt;br /&gt;so I wired up a an osgi Activator to write pidfile on  start.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/2472365566103396092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/2472365566103396092'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1273534317564#c2472365566103396092' title=''/><author><name>Brett</name><uri>http://www.blogger.com/profile/15876213791801206384</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-256284013'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5097533949640381358</id><published>2009-12-25T16:40:54.771-08:00</published><updated>2009-12-25T16:40:54.771-08:00</updated><title type='text'>Hey Igor

You can also check out my project for mo...</title><content type='html'>Hey Igor&lt;br /&gt;&lt;br /&gt;You can also check out my project for monitoring performance in Java. I just added a call for pid: &lt;a href="http://bit.ly/javasysmon" rel="nofollow"&gt;JavaSysMon at GitHub&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5097533949640381358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5097533949640381358'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1261788054771#c5097533949640381358' title=''/><author><name>Jez Humble</name><uri>http://www.blogger.com/profile/10321354226835044785</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-468576620'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-6599384457762659045</id><published>2009-11-12T21:23:13.653-08:00</published><updated>2009-11-12T21:23:13.653-08:00</updated><title type='text'>Hi all,

I tried the reflection technique , it wor...</title><content type='html'>Hi all,&lt;br /&gt;&lt;br /&gt;I tried the reflection technique , it works only on linux.&lt;br /&gt;&lt;br /&gt;We get &amp;#39;java.lang.NoSuchFieldException: pid&amp;#39;&lt;br /&gt;on windows.&lt;br /&gt;&lt;br /&gt;with regards,&lt;br /&gt;ch vishnu213</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6599384457762659045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6599384457762659045'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1258089793653#c6599384457762659045' title=''/><author><name>vishnu</name><uri>http://www.blogger.com/profile/13865191899113945498</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-184016172'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-7108280652112199860</id><published>2009-09-09T11:32:58.278-07:00</published><updated>2009-09-09T11:32:58.278-07:00</updated><title type='text'>jps is the best way to find a pid for an external ...</title><content type='html'>jps is the best way to find a pid for an external jvm process. The methods I captured in my blog post deal with discovering the process pid from within the java application.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/7108280652112199860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/7108280652112199860'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1252521178278#c7108280652112199860' title=''/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1473152891'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-3696482057429250592</id><published>2009-09-09T10:00:13.456-07:00</published><updated>2009-09-09T10:00:13.456-07:00</updated><title type='text'>One more method -- exec jps (available in all JDKs...</title><content type='html'>One more method -- exec jps (available in all JDKs) and find the pid by the classname.&lt;br /&gt;&lt;br /&gt;What nonsense this is!!&lt;br /&gt;&lt;br /&gt;As to the argument of there maybe being an OS that does not use pid -- no problem.  Return -1 in that case!  Why should we use the lowest common denominator?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/3696482057429250592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/3696482057429250592'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1252515613456#c3696482057429250592' title=''/><author><name>Byron Nevins</name><uri>http://www.blogger.com/profile/06536180236748376172</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-353162917'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-8055456715374890269</id><published>2009-09-02T08:59:25.144-07:00</published><updated>2009-09-02T08:59:25.144-07:00</updated><title type='text'>Keep in mind that $PPID returns the pid of the par...</title><content type='html'>Keep in mind that $PPID returns the pid of the parent process. So it won&amp;#39;t return the process of the newly spawned process, but rather the pid of its parent, which is the JVM process.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8055456715374890269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8055456715374890269'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1251907165144#c8055456715374890269' title=''/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1473152891'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-8270517362540447459</id><published>2009-09-02T02:11:14.333-07:00</published><updated>2009-09-02T02:11:14.333-07:00</updated><title type='text'>If the JVM starts a new bash process, wouldn&amp;#39;t...</title><content type='html'>If the JVM starts a new bash process, wouldn&amp;#39;t the $PPID returned be the pid of the bash process, rather than the pid of the JVM?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8270517362540447459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8270517362540447459'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1251882674333#c8270517362540447459' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-737779007'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-1690662761906385526</id><published>2009-08-10T15:22:14.372-07:00</published><updated>2009-08-10T15:22:14.372-07:00</updated><title type='text'>The program above prints different values for a PI...</title><content type='html'>The program above prints different values for a PID because... well... they are really different process IDs!&lt;br /&gt;&lt;br /&gt;peter@peter:~/workspace/pidtest$ java -jar ./pidtest.jar&lt;br /&gt;5539&lt;br /&gt;5541&lt;br /&gt;5543&lt;br /&gt;5545&lt;br /&gt;5547&lt;br /&gt;5549&lt;br /&gt;5551&lt;br /&gt;5553&lt;br /&gt;5555&lt;br /&gt;5557&lt;br /&gt;&lt;br /&gt;On Unix systems, every time an image is loaded into memory, a new process is created.&lt;br /&gt;&lt;br /&gt;When you run ...&lt;br /&gt;&lt;br /&gt;Process p = Runtime.getRuntime ().exec (cmd);&lt;br /&gt;&lt;br /&gt;... several times, you are creating several processes and you should expect different PIDs. This is perfectly normal.&lt;br /&gt;&lt;br /&gt;Richard Gomes&lt;br /&gt;http://www.jquantlib.org/index.php/User:RichardGomes&lt;br /&gt;twitter: frgomes&lt;br /&gt;&lt;br /&gt;JQuantlib is a Library for Quantitative Finance written in Java.&lt;br /&gt;http://www.jquantlib.org/&lt;br /&gt;twitter: jquantlib</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1690662761906385526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1690662761906385526'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1249942934372#c1690662761906385526' title=''/><author><name>rgomes1997</name><uri>http://www.blogger.com/profile/10993828277309610363</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-430763906'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-8852865859775695644</id><published>2009-07-30T03:06:07.397-07:00</published><updated>2009-07-30T03:06:07.397-07:00</updated><title type='text'>Thanx dude... really helped me out!!</title><content type='html'>Thanx dude... really helped me out!!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8852865859775695644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/8852865859775695644'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1248948367397#c8852865859775695644' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1879786887'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5103825951512366564</id><published>2009-03-03T08:24:00.000-08:00</published><updated>2009-03-03T08:24:00.000-08:00</updated><title type='text'>Excellent overview. I think the Java management AP...</title><content type='html'>Excellent overview. I think the Java management API is the best approach, assuming your JVM is 1.5 or higher. I've used it on Windows XP (Sun JVM 1.5) and AIX 5.2 (IBM JVM 1.5).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5103825951512366564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5103825951512366564'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1236097440000#c5103825951512366564' title=''/><author><name>Al</name><uri>http://www.blogger.com/profile/02744452573753284598</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1476959285'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-4893111307008068991</id><published>2009-02-20T09:13:00.000-08:00</published><updated>2009-02-20T09:13:00.000-08:00</updated><title type='text'>worked perfectly on linux x86:&lt;br&gt;12766@hostname</title><content type='html'>worked perfectly on linux x86:&lt;BR/&gt;12766@hostname</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4893111307008068991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4893111307008068991'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1235149980000#c4893111307008068991' title=''/><author><name>Roger Pack</name><uri>http://www.blogger.com/profile/01578246846716577925</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1264410931'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-3358575917517531969</id><published>2008-08-05T15:23:00.000-07:00</published><updated>2008-08-05T15:23:00.000-07:00</updated><title type='text'>Hi, Igor -- you have a beautiful talent for unders...</title><content type='html'>Hi, Igor -- you have a beautiful talent for understatement!  ("not pretty", indeed!)&lt;BR/&gt;&lt;BR/&gt;Is there something like /proc/self for Solaris?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/3358575917517531969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/3358575917517531969'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1217974980000#c3358575917517531969' title=''/><author><name>Charles Roth</name><uri>http://thedance.net</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-85688370'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-5796959062578197187</id><published>2008-08-04T09:58:00.000-07:00</published><updated>2008-08-04T09:58:00.000-07:00</updated><title type='text'>Hi Charles,&lt;br&gt;&lt;br&gt;your solution is not pretty, bu...</title><content type='html'>Hi Charles,&lt;BR/&gt;&lt;BR/&gt;your solution is not pretty, but hey in this case it's better than nothing ;-)&lt;BR/&gt;&lt;BR/&gt;/i</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5796959062578197187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/5796959062578197187'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1217869080000#c5796959062578197187' title=''/><author><name>Igor Minar</name><uri>http://www.blogger.com/profile/03520548417275543432</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1473152891'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-2141266814399466383</id><published>2008-08-04T09:38:00.000-07:00</published><updated>2008-08-04T09:38:00.000-07:00</updated><title type='text'>Igor -- thanks for starting this.&lt;br&gt;&lt;br&gt;I wanted ...</title><content type='html'>Igor -- thanks for starting this.&lt;BR/&gt;&lt;BR/&gt;I wanted to find out not only the process id of the entire process, but also the thread id (aka "lightweight process id") of new threads.&lt;BR/&gt;&lt;BR/&gt;I found a kluge that works, most of the time, under linux -- described in detail at http://thedance.net/~roth/TECHBLOG/threadtracker.html&lt;BR/&gt;&lt;BR/&gt;Basically it involves reading /proc/self/task multiple times to look for new threads as they get created.  This is linux-only, but could possibly be adapted to other *nixes.&lt;BR/&gt;&lt;BR/&gt;Cheers!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/2141266814399466383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/2141266814399466383'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1217867880000#c2141266814399466383' title=''/><author><name>Charles Roth</name><uri>http://thedance.net</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-223066424'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-6280297892818828479</id><published>2008-07-02T12:04:00.000-07:00</published><updated>2008-07-02T12:04:00.000-07:00</updated><title type='text'>I found that the method retrieving name from runti...</title><content type='html'>I found that the method retrieving name from runtime mbean works fine under Linux and Mac OS X, for Windows I have not an test enviroment.&lt;BR/&gt;Great solution, Thanks a lot.&lt;BR/&gt;&lt;BR/&gt;Jan</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6280297892818828479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/6280297892818828479'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1215025440000#c6280297892818828479' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-272903751'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-1404769424618210605</id><published>2008-06-30T03:38:00.000-07:00</published><updated>2008-06-30T03:38:00.000-07:00</updated><title type='text'>Excellent man. The reflection solution works prett...</title><content type='html'>Excellent man. The reflection solution works pretty good and thanks a lot.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1404769424618210605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1404769424618210605'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1214822280000#c1404769424618210605' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-846946416'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-1548874282679725378</id><published>2007-10-19T10:15:00.000-07:00</published><updated>2007-10-19T10:15:00.000-07:00</updated><title type='text'>Reflection will also work. On UNIX the subclass of...</title><content type='html'>Reflection will also work. On UNIX the subclass of Process has a private field with the PID that the default JVM security settings allow you to get via reflection:&lt;BR/&gt;&lt;BR/&gt;    static int getPID(Process process)&lt;BR/&gt;        throws IllegalAccessException, IllegalArgumentException,&lt;BR/&gt;        NoSuchFieldException, SecurityException&lt;BR/&gt;    {&lt;BR/&gt;        Field field = process.getClass().getDeclaredField("pid");&lt;BR/&gt;        field.setAccessible(true);&lt;BR/&gt;        return field.getInt(process);&lt;BR/&gt;    }</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1548874282679725378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/1548874282679725378'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1192814100000#c1548874282679725378' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-695326238'/></entry><entry><id>tag:blogger.com,1999:blog-6406593750327945950.post-4752642742765808582</id><published>2007-07-31T03:26:00.000-07:00</published><updated>2007-07-31T03:26:00.000-07:00</updated><title type='text'>Dear John,&lt;br&gt;&lt;br&gt;very many thanks for that soluti...</title><content type='html'>Dear John,&lt;BR/&gt;&lt;BR/&gt;very many thanks for that solution! It works excellently! I hope is that this method is portable across Linux distributions and here to stay for the future. Forgive my ignorance on this...&lt;BR/&gt;&lt;BR/&gt;I have tried the method with a test program using the proposed code and got the following output:&lt;BR/&gt;&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;18810&lt;BR/&gt;&lt;BR/&gt;/*******************************************************************************&lt;BR/&gt; *                           tpidtest.java &lt;BR/&gt; *                         ------------------- &lt;BR/&gt; *             initial author : Peter Hoppe &lt;BR/&gt; *             copyright      : (C) 2007 &lt;BR/&gt; ******************************************************************************/&lt;BR/&gt;&lt;BR/&gt;/*******************************************************************************&lt;BR/&gt; * &lt;BR/&gt; * This program is free software; you can redistribute it and/or modify it under&lt;BR/&gt; * the terms of the GNU General Public License as published by the Free Software&lt;BR/&gt; * Foundation; either version 3 of the License, or (at your option) any later&lt;BR/&gt; * version.&lt;BR/&gt; * &lt;BR/&gt; * This program is distributed in the hope that it will be useful, but WITHOUT &lt;BR/&gt; * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or &lt;BR/&gt; * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for &lt;BR/&gt; * more details.&lt;BR/&gt; *&lt;BR/&gt; * You should have received a copy of the GNU General Public License along with&lt;BR/&gt; * this program; if not, write to the Free Software Foundation, Inc., 675 Mass&lt;BR/&gt; * Ave, Cambridge, MA 02139, USA.&lt;BR/&gt; * &lt;BR/&gt; ******************************************************************************/&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;package org.rww.mmailstarter.test;&lt;BR/&gt;&lt;BR/&gt;import java.io.File;&lt;BR/&gt;import java.io.IOException;&lt;BR/&gt;&lt;BR/&gt;/**&lt;BR/&gt; * Prints (to stdout) the PID of the java process that runs this program.&lt;BR/&gt; * &lt;BR/&gt; * The PID discovery method is specific to the Linux Operating system and &lt;BR/&gt; * may not work on other operating systems.&lt;BR/&gt; */&lt;BR/&gt;public class TPidTest&lt;BR/&gt;{&lt;BR/&gt;    public static void main (String [] args)&lt;BR/&gt;    {&lt;BR/&gt;        int i   = 0;&lt;BR/&gt;        int pid = 0;&lt;BR/&gt;        &lt;BR/&gt;        try&lt;BR/&gt;        {&lt;BR/&gt;            for (i = 0; i &lt; 10; i++)&lt;BR/&gt;            {&lt;BR/&gt;                pid = Integer.parseInt( ( new File("/proc/self")).getCanonicalFile().getName() );&lt;BR/&gt;                System.out.println (pid);&lt;BR/&gt;            }&lt;BR/&gt;        }&lt;BR/&gt;        catch (NumberFormatException e)&lt;BR/&gt;        {&lt;BR/&gt;            e.printStackTrace();&lt;BR/&gt;        }&lt;BR/&gt;        catch (IOException e)&lt;BR/&gt;        {&lt;BR/&gt;            e.printStackTrace();&lt;BR/&gt;        }&lt;BR/&gt;    }&lt;BR/&gt;}</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4752642742765808582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6406593750327945950/2447797443819124233/comments/default/4752642742765808582'/><link rel='alternate' type='text/html' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html?showComment=1185877560000#c4752642742765808582' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html' ref='tag:blogger.com,1999:blog-6406593750327945950.post-2447797443819124233' source='http://www.blogger.com/feeds/6406593750327945950/posts/default/2447797443819124233' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-727344489'/></entry></feed>
