<?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"
	>

<channel>
	<title>Just answer the F*#king question &#187; J2ME</title>
	<atom:link href="http://www.jatfq.com/archives/category/usefull-stuff/java/j2me/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jatfq.com</link>
	<description>Saving the world from dicks with forum logins ...</description>
	<pubDate>Mon, 03 Nov 2008 17:18:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Serve JAD files OTA with PHP</title>
		<link>http://www.jatfq.com/archives/62</link>
		<comments>http://www.jatfq.com/archives/62#comments</comments>
		<pubDate>Mon, 03 Nov 2008 17:14:41 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[J2ME]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/?p=62</guid>
		<description><![CDATA[Some handy code to dynamtically serve JAD files for OTA installation. The below script sets the appropriate headers types, also tidies up the JAD file removing stray characters which can cause issues and setting the correct file paths internally.
Place the PH script in a root directory as serveJAD.php. Place your JAR and JAD files in [...]]]></description>
			<content:encoded><![CDATA[<p>Some handy code to dynamtically serve JAD files for OTA installation. The below script sets the appropriate headers types, also tidies up the JAD file removing stray characters which can cause issues and setting the correct file paths internally.</p>
<p>Place the PH script in a root directory as serveJAD.php. Place your JAR and JAD files in a subdirectory /J2ME</p>
<p>Call the script by serveJAD.php?format=J2ME&#038;file={jad minus extension} or you can use the Apache rewrite below and call as /J2ME/file.jad</p>
<p>ie</p>
<p>serveJAD.php?format=J2ME&#038;file=game</p>
<p>or with Apache rewrite </p>
<p>/J2ME/game.jad</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #0000ff;">$format</span>   = <span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;format&quot;</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$file</span>     = <span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">&quot;.jad&quot;</span>;
    <span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Cache-Control: no-cache, must-revalidate,no-transform&quot;</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Pragma: no-cache&quot;</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-type: text/vnd.sun.j2me.app-descriptor&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Disposition: attachment; filename=&quot;</span>.<span style="color: #0000ff;">$file</span>.<span style="color: #ff0000;">&quot;;&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0000ff;">$jad</span> = <span style="color: #000066;">file_get_contents</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;./&quot;</span>.<span style="color: #0000ff;">$format</span>.<span style="color: #ff0000;">&quot;/&quot;</span>.<span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0000ff;">$lines</span> = <span style="color: #000066;">explode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #0000ff;">$jad</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0000ff;">$final</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
	<span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$lines</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$line</span> = <span style="color: #000066;">trim</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">strlen</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0000ff;">$keypair</span> = <span style="color: #000066;">explode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;: &quot;</span>,<span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #ff0000;">'MIDlet-Jar-URL'</span> || <span style="color: #000066;">stristr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #ff0000;">&quot;RIM-COD-URL&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #0000ff;">$url</span> = <span style="color: #000066;">trim</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">stristr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span>,<span style="color: #ff0000;">&quot;http:&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
					<span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;http://&quot;</span>.<span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;HTTP_HOST&quot;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">&quot;/$format/&quot;</span>.<span style="color: #0000ff;">$url</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #ff0000;">'MIDlet-Jar-Size'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> =  <span style="color: #000066;">filesize</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;./&quot;</span>.<span style="color: #0000ff;">$format</span>.<span style="color: #ff0000;">&quot;/&quot;</span>.<span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">&quot;.jar&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0000ff;">$line</span> = <span style="color: #000066;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;: &quot;</span>,<span style="color: #0000ff;">$keypair</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0000ff;">$l</span> = <span style="color: #000066;">trim</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$final</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #0000ff;">$final</span>.=<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
			<span style="color: #0000ff;">$final</span>.=<span style="color: #0000ff;">$l</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #000066;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$final</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><code><br />
    RewriteEngine On<br />
    RewriteRule /J2ME/(.*)\.jad /serveJAD.php?format=J2ME&#038;file=$1<br />
</code></p>
<p>You can also use this to build automatic index pages, using this as dir.php?format=J2ME</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #0000ff;">$format</span>   = <span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;format&quot;</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$scanthis</span> = <span style="color: #ff0000;">&quot;./&quot;</span>.<span style="color: #0000ff;">$format</span>;
 	<span style="color: #0000ff;">$scanlisting</span> = scandir<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$scanthis</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$dirlisting</span> = <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$scanlisting</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$key</span> =&gt; <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">stristr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span>,<span style="color: #ff0000;">&quot;jad&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0000ff;">$name</span> = <span style="color: #000066;">explode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span>,<span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0000ff;">$dirlisting</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #000066;">ksort</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dirlisting</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;!DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;
&lt;html xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;
&lt;head&gt;
&lt;link href=<span style="color: #ff0000;">&quot;apps.css&quot;</span> rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> /&gt;
&lt;meta http-equiv=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> content=<span style="color: #ff0000;">&quot;text/html; charset=iso-8859-1&quot;</span> /&gt;
&lt;title&gt;Application listing&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dirlisting</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;a href=<span style="color: #ff0000;">&quot;/&lt;?php print($format);?&gt;/&lt;?php print($name);?&gt;.jad&quot;</span>&gt;&lt;?php <span style="color: #000066;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span>;?&gt;&lt;/a&gt;&lt;br /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span>
?&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F62&amp;title=Serve+JAD+files+OTA+with+PHP" title="Stumble it!"><img src="/icon_stumbleupon.gif" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/62/feed</wfw:commentRss>
		</item>
		<item>
		<title>Drawing filled polygons in J2ME</title>
		<link>http://www.jatfq.com/archives/8</link>
		<comments>http://www.jatfq.com/archives/8#comments</comments>
		<pubDate>Fri, 11 May 2007 13:13:17 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[J2ME]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Useful stuff]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/8</guid>
		<description><![CDATA[Check this sourceforge project for a really useful class.
http://sourceforge.net/projects/jmicropolygon/
Works really well on most of the phones we have tried it one. Once you have this class you can then do filled and stroked thick lines in J2ME.









]]></description>
			<content:encoded><![CDATA[<p>Check this sourceforge project for a really useful class.</p>
<p><a href="http://sourceforge.net/projects/jmicropolygon/">http://sourceforge.net/projects/jmicropolygon/</a></p>
<p>Works really well on most of the phones we have tried it one. Once you have this class you can then do filled and stroked thick lines in J2ME.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F8&amp;title=Drawing+filled+polygons+in+J2ME" title="Stumble it!"><img src="/icon_stumbleupon.gif" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/8/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
