<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Java Application &#8211; Make sure only single/one instance running &#8211; with File Lock and ShutdownHook</title>
	<atom:link href="http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/</link>
	<description>My name is Jimmy, and this is my story... ;)</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:01:53 +0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Omar</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-282</link>
		<dc:creator>Omar</dc:creator>
		<pubDate>Thu, 26 Aug 2010 16:25:09 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-282</guid>
		<description>On Red Hat with Java 1.6 I experienced that the f.delete() were allowed and each new process would therefor delete the lock before trying to acquire it. It worked perfectly after I removed the same bit of code as sassubra mentioned.</description>
		<content:encoded><![CDATA[<p>On Red Hat with Java 1.6 I experienced that the f.delete() were allowed and each new process would therefor delete the lock before trying to acquire it. It worked perfectly after I removed the same bit of code as sassubra mentioned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-265</link>
		<dc:creator>Derek</dc:creator>
		<pubDate>Thu, 15 Jul 2010 21:10:41 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-265</guid>
		<description>@Sassubra
Why would that work?</description>
		<content:encoded><![CDATA[<p>@Sassubra<br />
Why would that work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sassubra</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-240</link>
		<dc:creator>sassubra</dc:creator>
		<pubDate>Mon, 17 May 2010 21:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-240</guid>
		<description>You can remove the following lines from the code:

if (f.exists()) {
 // if exist try to delete it
 f.delete();
}

So that your code will work in solaris too.</description>
		<content:encoded><![CDATA[<p>You can remove the following lines from the code:</p>
<p>if (f.exists()) {<br />
 // if exist try to delete it<br />
 f.delete();<br />
}</p>
<p>So that your code will work in solaris too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-222</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Wed, 14 Apr 2010 05:07:45 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-222</guid>
		<description>@Peter:
Glad my article can help you
Cheers :)</description>
		<content:encoded><![CDATA[<p>@Peter:<br />
Glad my article can help you<br />
Cheers <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Davids</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-221</link>
		<dc:creator>Peter Davids</dc:creator>
		<pubDate>Tue, 13 Apr 2010 13:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-221</guid>
		<description>Jimmy,

I just wanted to thank you for this solution. For a schoolproject I need to make a client/server solution, where there can be only one server instance because it has to be bound to a comport. I had tried the port/serversocket solution at first but found out that after longer periods of running ( &gt; 3 days non-stop) the socket appeared to be open again and I could run a a second instance (which fubarred my complete app :D ). Your solution has been stable for 5 days both on a windows and a linux system.

So again, my thanks :-)

Cheers!

Peter
Groningen, the Netherlands</description>
		<content:encoded><![CDATA[<p>Jimmy,</p>
<p>I just wanted to thank you for this solution. For a schoolproject I need to make a client/server solution, where there can be only one server instance because it has to be bound to a comport. I had tried the port/serversocket solution at first but found out that after longer periods of running ( &gt; 3 days non-stop) the socket appeared to be open again and I could run a a second instance (which fubarred my complete app <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ). Your solution has been stable for 5 days both on a windows and a linux system.</p>
<p>So again, my thanks <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Cheers!</p>
<p>Peter<br />
Groningen, the Netherlands</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-203</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Wed, 30 Sep 2009 08:37:29 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-203</guid>
		<description>Sorry for not replying your comment fast

@Nayanish : I&#039;m not really familiar with solaris so I don&#039;t think I can give solution for now.

@rnb : I assuming you&#039;re creating desktop application with JSE. The concept will be the same, but you need to learn / find tutorial about AWT/Swing.. depends on the one you using.

@xyz : depends on how you design the locking file folder, the sample was use current folder from where  user running it.
To prevent mistake, you can create example a bash script to running it so it will change to specific folder first.
Or put the lock file in absolute path.
Using socket is also a solution, but it will take 1 port for each.. depends on your need, if you need 1000 app with 1000 locking, using port will takes to much port.</description>
		<content:encoded><![CDATA[<p>Sorry for not replying your comment fast</p>
<p>@Nayanish : I&#8217;m not really familiar with solaris so I don&#8217;t think I can give solution for now.</p>
<p>@rnb : I assuming you&#8217;re creating desktop application with JSE. The concept will be the same, but you need to learn / find tutorial about AWT/Swing.. depends on the one you using.</p>
<p>@xyz : depends on how you design the locking file folder, the sample was use current folder from where  user running it.<br />
To prevent mistake, you can create example a bash script to running it so it will change to specific folder first.<br />
Or put the lock file in absolute path.<br />
Using socket is also a solution, but it will take 1 port for each.. depends on your need, if you need 1000 app with 1000 locking, using port will takes to much port.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xyz</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-202</link>
		<dc:creator>xyz</dc:creator>
		<pubDate>Wed, 30 Sep 2009 06:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-202</guid>
		<description>A FLAW!!
what if i copy the application to some other directory and run it? in this case, the application can be run easily. rather use a &quot;UNIQUE&quot; location for the &quot;.lock&quot; file or implement the whole mechanism using sockets.
use some port &quot;xyz&quot; on the system to check the mechanism.</description>
		<content:encoded><![CDATA[<p>A FLAW!!<br />
what if i copy the application to some other directory and run it? in this case, the application can be run easily. rather use a &#8220;UNIQUE&#8221; location for the &#8220;.lock&#8221; file or implement the whole mechanism using sockets.<br />
use some port &#8220;xyz&#8221; on the system to check the mechanism.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rnb</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-201</link>
		<dc:creator>rnb</dc:creator>
		<pubDate>Sun, 06 Sep 2009 20:20:44 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-201</guid>
		<description>&quot;show error that there’s already an instance running&quot; - how show that &quot;error&quot; in the dialog window?</description>
		<content:encoded><![CDATA[<p>&#8220;show error that there’s already an instance running&#8221; &#8211; how show that &#8220;error&#8221; in the dialog window?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nayanish</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-198</link>
		<dc:creator>Nayanish</dc:creator>
		<pubDate>Tue, 01 Sep 2009 03:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-198</guid>
		<description>Hi,

&gt;&gt; File locking cannot be implemented on Solaris operating system because its file lock is advisory where as on Window platform its mandatory.

Any workaround for this?

Thanks
Nayn</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>&gt;&gt; File locking cannot be implemented on Solaris operating system because its file lock is advisory where as on Window platform its mandatory.</p>
<p>Any workaround for this?</p>
<p>Thanks<br />
Nayn</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://jimmod.com/blog/2008/07/java-application-make-sure-only-singleone-instance-running-with-file-lock-ampampampampamp-shutdownhook/comment-page-1/#comment-158</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Mon, 22 Jun 2009 09:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/07/21/java-application-make-sure-only-singleone-instance-running-with-file-lock-shutdownhook/#comment-158</guid>
		<description>Works great. Thank you!</description>
		<content:encoded><![CDATA[<p>Works great. Thank you!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
