<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Metacosm &#187; java</title>
	<atom:link href="http://codepuccino.com/metacosm/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepuccino.com/metacosm</link>
	<description>This is not a tag line!</description>
	<lastBuildDate>Tue, 13 Apr 2010 15:24:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Beware of File.createTempFile</title>
		<link>http://codepuccino.com/metacosm/2009/09/04/beware-of-file-createtempfile/</link>
		<comments>http://codepuccino.com/metacosm/2009/09/04/beware-of-file-createtempfile/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 18:28:45 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[gotcha]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://codepuccino.com/metacosm/?p=467</guid>
		<description><![CDATA[By default, File.createTempFile (in Java, of course) creates a temporary file in the directory identified by the system property java.io.tmpdir. The problem is that on OS X, that directory can be quite weird. For example, on my system, it currently is: scala&#62; System.getProperties().getProperty(&#34;java.io.tmpdir&#34;) res0: java.lang.String = /var/folders/ya/yaNATrKPGFu2HuSOWxSIu++++TI/-Tmp-/ Notice the ++++ in one of the directory


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>By default, <code>File.createTempFile</code> (in Java, of course) creates a temporary file in the directory identified by the system property <code>java.io.tmpdir</code>. The problem is that on OS X, that directory can be quite weird. For example, on my system, it currently is:</p>
<pre class="brush: scala;">
scala&gt; System.getProperties().getProperty(&quot;java.io.tmpdir&quot;)
res0: java.lang.String = /var/folders/ya/yaNATrKPGFu2HuSOWxSIu++++TI/-Tmp-/
</pre>
<p>Notice the <code>++++</code> in one of the directory names? Well, these little characters can later cause headaches! The reason, you ask? Simple, if that temporary file name is ever used in a URL, then those plus signs will be interpreted as spaces and whatever code is using a URL to find your temporary file will not find it! So beware!</p>
<p>Possible solutions include passing <code>-Djava.io.tmpdir="whatever"</code> when you launch your Java process, or use the <code>createTempFile(String prefix, String suffix, File directory)</code> version of <code>File.createTempFile</code> and pass it a directory that doesn&#8217;t contain an <code>+</code> sign in its name!</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://codepuccino.com/metacosm/2009/09/04/beware-of-file-createtempfile/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Accessing a JMX object programmatically from JBoss</title>
		<link>http://codepuccino.com/metacosm/2006/04/15/accessing-a-jmx-object-programmatically-from-jboss/</link>
		<comments>http://codepuccino.com/metacosm/2006/04/15/accessing-a-jmx-object-programmatically-from-jboss/#comments</comments>
		<pubDate>Sat, 15 Apr 2006 06:28:31 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[jboss]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jmx]]></category>

		<guid isPermaLink="false">http://blogs.codepuccino.com/metacosm/archives/2006/04/15/accessing-a-jmx-object-programmatically-from-jboss/</guid>
		<description><![CDATA[OK so here&#8217;s some geeky information&#8230; I&#8217;ve had several times the need to access a JMX service programmatically and each time, I had to hunt down the information so here it is so that I know where to find it next time. It took me three years almost to the days to need that piece


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>OK so here&#8217;s some geeky information&#8230; I&#8217;ve had several times the need to access a JMX service programmatically and each time, I had to hunt down the information so here it is so that I know where to find it next time.</p>
<p class="update" title="April 16, 2009">It took me three years almost to the days to need that piece of code again and realize that it wouldn&#8217;t even compile&#8230; Should be fixed now!</p>
<pre class="brush: java;">
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanProxyCreationException;
import org.jboss.mx.util.MBeanServerLocator;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

ObjectName objectName;
String name;
try {
	objectName = new ObjectName(name);
} catch (MalformedObjectNameException e) {
	throw new IllegalArgumentException(&quot;'&quot; + name + &quot;' is not a valid ObjectName&quot;);
}
MBeanServer server = MBeanServerLocator.locateJBoss();
try {
	return MBeanProxy.get(clazz, objectName, server);
} catch (MBeanProxyCreationException e) {
	String message = &quot;Couldn't retrieve '&quot; + objectName.getCanonicalName() + &quot;' MBean with class &quot; + clazz.getName();
	throw new RuntimeException(message, e);
}
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://codepuccino.com/metacosm/2006/04/15/accessing-a-jmx-object-programmatically-from-jboss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
