<?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; Java</title>
	<atom:link href="http://www.jatfq.com/archives/category/usefull-stuff/java/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>Converting a Midlet to a COD file for OTA installation</title>
		<link>http://www.jatfq.com/archives/20</link>
		<comments>http://www.jatfq.com/archives/20#comments</comments>
		<pubDate>Thu, 14 Feb 2008 15:01:19 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[RIM / Blackberry]]></category>

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

		<guid isPermaLink="false">http://www.jatfq.com/archives/20</guid>
		<description><![CDATA[God, RIM sucks. Thought I&#8217;d mention that. I hate Blackberries with passion. Really.
Now, if you are converting a Midlet to a COD file, you will need to use the infamous rapc tool provided with the RIM JDE ( in the bin directory if you are looking for it ) . Now, along with issues with [...]]]></description>
			<content:encoded><![CDATA[<p>God, RIM sucks. Thought I&#8217;d mention that. I hate Blackberries with passion. Really.</p>
<p>Now, if you are converting a Midlet to a COD file, you will need to use the infamous rapc tool provided with the RIM JDE ( in the bin directory if you are looking for it ) . Now, along with issues with multiple versions, bugs and what have you, one big pain is if you want the RIM version of the JAD file created for OTA installation, rapc doesn&#8217;t give you all the parameters if you use the -midlet paramater. If you DON&#8217;T use it, you get a nice JAD but the COD will not work.</p>
<p>So, to get around this, I created a small app to extract the RIM specfic information from the COD file generated by rapc.</p>
<p>Generated the COD using</p>
<p><code>rapc import="%jde%\lib\net_rim_api.jar" codename=%jar% -midlet jad=%jar%.jad %jar%.jar </code></p>
<p>where %jde% is your JDE path, %jar% is the name of your module.</p>
<p><a href='http://www.jatfq.com/wp-content/uploads/2008/02/cod2jad.jar' title='Extract JAD information from a COD file'>Extract JAD information from a COD file</a></p>
<p>To run:</p>
<p><code>java -jar cod2jad.jar {cod file} {module name}</code></p>
<p>This will dump the extra information to stdout, so you can just append it to your JAD file with >>, ie</p>
<p><code>java -jar cod2jad.jar path.cod myapp >> path.jad</code></p>
<p>Remember, once you have done this, open the COD file in winzip ( or whatever ) and extract the seperate elements to your webserver. Once note, if you COD is only made of one module, this will probably fail ( sorry ).</p>
<p>Oh, and if you are using Netbeans components, and/or getting verification errors, try turning down your obfusication level in your project - rapc hates the splash screen and wait screen when obfusicated for some reason.  The other option is to try including the net_rim_api.jar in your project ( but don&#8217;t include in the package ).</p>
<p>And even nicer of me, here is the source code:</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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
</pre></td><td class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">magnetmobile</span>.<span style="color: #006600;">tools</span>.<span style="color: #006600;">rim</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">/**
 *
 * @author Sime when drunk ... yay drunk code
 */</span>
<span style="color: #a1a100;">import java.io.*;</span>
<span style="color: #a1a100;">import java.util.*;</span>
<span style="color: #a1a100;">import java.util.jar.*;</span>
<span style="color: #a1a100;">import java.io.UnsupportedEncodingException;</span>
<span style="color: #a1a100;">import java.security.MessageDigest;</span>
<span style="color: #a1a100;">import java.security.NoSuchAlgorithmException;</span>
<span style="color: #a1a100;">import java.util.logging.Level;</span>
<span style="color: #a1a100;">import java.util.logging.Logger;</span>
<span style="color: #a1a100;">import java.util.zip.ZipEntry;</span>
<span style="color: #a1a100;">import java.util.zip.ZipInputStream;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Cod2Jad <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> args<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #aaaadd; font-weight: bold;">NoSuchAlgorithmException</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #aaaadd; font-weight: bold;">FileInputStream</span> fis = <span style="color: #000000; font-weight: bold;">null</span>;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #993333;">int</span> count = <span style="color: #cc66cc;">0</span>;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>args.<span style="color: #006600;">length</span> != <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;usage: {path to COD} {Module name}&quot;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #aaaadd; font-weight: bold;">Hashtable</span> htSizes = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Hashtable</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #aaaadd; font-weight: bold;">Hashtable</span> htJarContents = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Hashtable</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            fis = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">FileInputStream</span><span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
            <span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span> bis = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span><span style="color: #66cc66;">&#40;</span>fis<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #aaaadd; font-weight: bold;">ZipInputStream</span> zis = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">ZipInputStream</span><span style="color: #66cc66;">&#40;</span>bis<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #aaaadd; font-weight: bold;">ZipEntry</span> ze = <span style="color: #000000; font-weight: bold;">null</span>;
            <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ze = zis.<span style="color: #006600;">getNextEntry</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #000000; font-weight: bold;">null</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>ze.<span style="color: #006600;">isDirectory</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">continue</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #993333;">int</span> size = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> ze.<span style="color: #006600;">getSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// -1 means unknown size.</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>size == <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    size = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Integer</span><span style="color: #66cc66;">&#41;</span> htSizes.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>ze.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">intValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> b = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> size<span style="color: #66cc66;">&#93;</span>;
                <span style="color: #993333;">int</span> rb = <span style="color: #cc66cc;">0</span>;
                <span style="color: #993333;">int</span> chunk = <span style="color: #cc66cc;">0</span>;
                <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> size - rb<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>
                    chunk = zis.<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span>b, rb, <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> size - rb<span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>chunk == <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">break</span>;
                    <span style="color: #66cc66;">&#125;</span>
                    rb += chunk;
                <span style="color: #66cc66;">&#125;</span>
                htJarContents.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span>ze.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, b<span style="color: #66cc66;">&#41;</span>;
                process<span style="color: #66cc66;">&#40;</span>ze, count, b<span style="color: #66cc66;">&#41;</span>;
                count++;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RIM-COD-Module-Name:&quot;</span> + args<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: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RIM-COD-Module-Dependencies: net_rim_cldc&quot;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RIM-COD-Creation-Time: 1202924527&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            zis.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            bis.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            fis.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">IOException</span> ex<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Could not access file &quot;</span>+args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
                fis.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">IOException</span> ex<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                Logger.<span style="color: #006600;">getLogger</span><span style="color: #66cc66;">&#40;</span>Cod2Jad.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span>Level.<span style="color: #006600;">SEVERE</span>, <span style="color: #000000; font-weight: bold;">null</span>, ex<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> process<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Object</span> obj, <span style="color: #993333;">int</span> count,<span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> data<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #aaaadd; font-weight: bold;">NoSuchAlgorithmException</span>,
<span style="color: #aaaadd; font-weight: bold;">UnsupportedEncodingException</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #aaaadd; font-weight: bold;">ZipEntry</span> entry = <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">ZipEntry</span><span style="color: #66cc66;">&#41;</span> obj;
        <span style="color: #aaaadd; font-weight: bold;">String</span> name = entry.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">long</span> size = entry.<span style="color: #006600;">getSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">long</span> compressedSize = entry.<span style="color: #006600;">getCompressedSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #aaaadd; font-weight: bold;">String</span> output = <span style="color: #ff0000;">&quot;RIM-COD-URL&quot;</span> + <span style="color: #66cc66;">&#40;</span>count &gt; <span style="color: #cc66cc;">0</span> ? <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;-&quot;</span> + count<span style="color: #66cc66;">&#41;</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;: &quot;</span> + name;
        <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>output<span style="color: #66cc66;">&#41;</span>;
&nbsp;
        output = <span style="color: #ff0000;">&quot;RIM-COD-Size&quot;</span> + <span style="color: #66cc66;">&#40;</span>count &gt; <span style="color: #cc66cc;">0</span> ? <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;-&quot;</span> + count<span style="color: #66cc66;">&#41;</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;: &quot;</span> + compressedSize;
        <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>output<span style="color: #66cc66;">&#41;</span>;
&nbsp;
        output = <span style="color: #ff0000;">&quot;RIM-COD-SHA1&quot;</span> + <span style="color: #66cc66;">&#40;</span>count &gt; <span style="color: #cc66cc;">0</span> ? <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;-&quot;</span> + count<span style="color: #66cc66;">&#41;</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;: &quot;</span>;
        output +=  SHA1<span style="color: #66cc66;">&#40;</span>data, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>output<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #aaaadd; font-weight: bold;">String</span> convertToHex<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> data, <span style="color: #993333;">boolean</span> spaced<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #aaaadd; font-weight: bold;">StringBuffer</span> buf = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">StringBuffer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &lt;
                data.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #993333;">int</span> halfbyte = <span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> &gt;&gt;&gt; <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> &amp; 0x0F;
            <span style="color: #993333;">int</span> two_halfs = <span style="color: #cc66cc;">0</span>;
            <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> &lt;= halfbyte<span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span>halfbyte &lt;= <span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    buf.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'0'</span> + halfbyte<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
                    buf.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'a'</span> + <span style="color: #66cc66;">&#40;</span>halfbyte - <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                halfbyte = data<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> &amp; 0x0F;
            <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>two_halfs++ &lt; <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>spaced<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                buf.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> buf.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #aaaadd; font-weight: bold;">String</span> SHA1<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> data, <span style="color: #993333;">boolean</span> spaced<span style="color: #66cc66;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #aaaadd; font-weight: bold;">NoSuchAlgorithmException</span>, <span style="color: #aaaadd; font-weight: bold;">UnsupportedEncodingException</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #aaaadd; font-weight: bold;">MessageDigest</span> md;
        md =
                <span style="color: #aaaadd; font-weight: bold;">MessageDigest</span>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SHA-1&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> sha1hash = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#93;</span>;
        md.<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span>data, <span style="color: #cc66cc;">0</span>, data.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span>;
        sha1hash =
                md.<span style="color: #006600;">digest</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> convertToHex<span style="color: #66cc66;">&#40;</span>sha1hash, spaced<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation', '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%2F20" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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%2F20&amp;title=Converting+a+Midlet+to+a+COD+file+for+OTA+installation" 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/20/feed</wfw:commentRss>
		</item>
		<item>
		<title>Java based Google Sitemap generator</title>
		<link>http://www.jatfq.com/archives/13</link>
		<comments>http://www.jatfq.com/archives/13#comments</comments>
		<pubDate>Sun, 21 Oct 2007 20:18:00 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/13</guid>
		<description><![CDATA[Very basic sitemap generator written in Java. Also useful for creating a dump of the URLs in your site ( pipe output to file )
Dowload here
This is still in beta form, but does work. Add your comments or request on this post.









]]></description>
			<content:encoded><![CDATA[<p>Very basic sitemap generator written in Java. Also useful for creating a dump of the URLs in your site ( pipe output to file )</p>
<p><a href="http://web-max.ca/freeware/ajSitemap.php">Dowload here</a></p>
<p>This is still in beta form, but does work. Add your comments or request on this post.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F13&amp;title=Java+based+Google+Sitemap+generator" 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%2F13&amp;title=Java+based+Google+Sitemap+generator" 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%2F13&amp;title=Java+based+Google+Sitemap+generator" 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%2F13&amp;title=Java+based+Google+Sitemap+generator" 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%2F13&amp;title=Java+based+Google+Sitemap+generator', '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%2F13" 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%2F13&amp;title=Java+based+Google+Sitemap+generator" 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%2F13&amp;title=Java+based+Google+Sitemap+generator" 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/13/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>
		<item>
		<title>Find the point at which 2 lines intersect</title>
		<link>http://www.jatfq.com/archives/7</link>
		<comments>http://www.jatfq.com/archives/7#comments</comments>
		<pubDate>Fri, 11 May 2007 13:07:50 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

		<guid isPermaLink="false">http://www.jatfq.com/archives/7</guid>
		<description><![CDATA[Given two lines ( defined as 2 x,y coordinates in an array ), this will return the x,y position at which the two lines intersect. If they do not intersect, it will return null.

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
public Coordinate intersects&#40;Coordinate&#91;&#93; coA,Coordinate&#91;&#93; coB &#41; &#123;
&#160;
        double x11 = coA&#91;0&#93;.getX&#40;&#41;;
     [...]]]></description>
			<content:encoded><![CDATA[<p>Given two lines ( defined as 2 x,y coordinates in an array ), this will return the x,y position at which the two lines intersect. If they do not intersect, it will return null.</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
</pre></td><td class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">public</span> Coordinate intersects<span style="color: #66cc66;">&#40;</span>Coordinate<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> coA,Coordinate<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> coB <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #993333;">double</span> x11 = coA<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getX</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> y11 = coA<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> x12 = coA<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getX</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> y12 = coA<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> x21 = coB<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getX</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> y21 = coB<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> x22 = coB<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getX</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">double</span> y22 = coB<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #993333;">double</span> dx1 = x12 - x11;
        <span style="color: #993333;">double</span> dy1 = y12 - y11;
        <span style="color: #993333;">double</span> dx2 = x22 - x21;
        <span style="color: #993333;">double</span> dy2 = y22 - y21;
        <span style="color: #993333;">double</span> det = <span style="color: #66cc66;">&#40;</span>dx2*dy1-dy2*dx1<span style="color: #66cc66;">&#41;</span>;
&nbsp;
        Coordinate coReturn = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>det != <span style="color: #cc66cc;">0.0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #993333;">double</span> mu = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x11 - x21<span style="color: #66cc66;">&#41;</span>*dy1 - <span style="color: #66cc66;">&#40;</span>y11 - y21<span style="color: #66cc66;">&#41;</span>*dx1<span style="color: #66cc66;">&#41;</span>/det;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mu &gt;= <span style="color: #cc66cc;">0.0</span>  &amp;&amp;  mu &lt;= <span style="color: #cc66cc;">1.0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                coReturn = <span style="color: #000000; font-weight: bold;">new</span> Coordinate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                coReturn.<span style="color: #006600;">setX</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>x21 + mu*dx2 + <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                coReturn.<span style="color: #006600;">setY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>y21 + mu*dy2 + <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>    
        <span style="color: #000000; font-weight: bold;">return</span> coReturn;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect', '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%2F7" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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%2F7&amp;title=Find+the+point+at+which+2+lines+intersect" 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/7/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
