<?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>FireTeam &#187; Programmazione Java</title>
	<atom:link href="http://www.fireteam.it/category/programmazione/programmazione-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fireteam.it</link>
	<description>#fuoco@AzzurraNet</description>
	<lastBuildDate>Tue, 16 Mar 2010 15:55:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Implementazione della funzione di Ackermann</title>
		<link>http://www.fireteam.it/2009/11/implementazione-della-funzione-di-ackermann/</link>
		<comments>http://www.fireteam.it/2009/11/implementazione-della-funzione-di-ackermann/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 15:55:55 +0000</pubDate>
		<dc:creator>saverio</dc:creator>
				<category><![CDATA[Programmazione Java]]></category>
		<category><![CDATA[ackermann]]></category>
		<category><![CDATA[calcolabilità]]></category>

		<guid isPermaLink="false">http://www.fireteam.it/?p=734</guid>
		<description><![CDATA[La funzione di Ackermann è una funzione f(x,y,z) che ha come dominio l&#8217;insieme delle terne di numeri naturali e come codominio i numeri naturali.

Essa è un esempio di funzione ricorsiva che non è primitiva ricorsiva poiché cresce più velocemente di qualsiasi funzione ricorsiva primitiva.
Qui il codice java che implementa questa funzione:

Ackermann.java

0
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
public class Ackermann &#123;
 
 static long [...]]]></description>
			<content:encoded><![CDATA[<p>La funzione di Ackermann è una funzione f(x,y,z) che ha come dominio l&#8217;insieme delle terne di numeri naturali e come codominio i numeri naturali.</p>
<p style="text-align: center;"><img class="size-full wp-image-736 aligncenter" title="ackermann" src="http://www.fireteam.it/wp-content/uploads/2009/11/ackermann.png" alt="ackermann" width="477" height="87" /></p>
<p>Essa è un esempio di funzione ricorsiva che non è primitiva ricorsiva poiché cresce più velocemente di qualsiasi funzione ricorsiva primitiva.</p>
<p>Qui il codice java che implementa questa funzione:</p>
<p><span id="more-734"></span></p>
<p><span style="text-decoration: underline;">Ackermann.java</span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
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
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Ackermann <span style="color: #009900;">&#123;</span>
 
 <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> count <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
 
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> h<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> m, <span style="color: #000066; font-weight: bold;">long</span> n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  
  count<span style="color: #339933;">++;</span>
  
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>m <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">return</span> n <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">return</span> h<span style="color: #009900;">&#40;</span>m<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  
  <span style="color: #000000; font-weight: bold;">return</span> h<span style="color: #009900;">&#40;</span>m<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>, h<span style="color: #009900;">&#40;</span>m,n<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> ack<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">return</span> h<span style="color: #009900;">&#40;</span>n, n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">length</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;usage: Ackermann &lt;number&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>where number is a positive integer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  
  <span style="color: #000066; font-weight: bold;">long</span> n <span style="color: #339933;">=</span> <span style="color: #003399;">Long</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  
  count <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">long</span> retValue <span style="color: #339933;">=</span> ack<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ack(&quot;</span> <span style="color: #339933;">+</span> n <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;) = &quot;</span> <span style="color: #339933;">+</span> retValue <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; [recursive calls = &quot;</span><span style="color: #339933;">+</span> count <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  
  <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Il meccanismo di calcolo della funzione è estremamente semplice quanto pesante dal punto di vista computazionale. Questi sono i risultati ottenuti:</p>
<ul>
<li>ack(0) = <strong>1</strong>  [recursive calls = <strong>1</strong>]</li>
<li>ack(1) = <strong>3</strong>  [recursive calls = <strong>4</strong>]</li>
<li>ack(2) = <strong>7</strong>  [recursive calls = <strong>27</strong>]</li>
<li>ack(3) = <strong>61</strong> [recursive calls = <strong>2432</strong>]</li>
</ul>
<p>Non riesco a calcolare ack(4) causa stack overflow (Exception in thread &#8220;main&#8221; java.lang.StackOverflowError).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fireteam.it/2009/11/implementazione-della-funzione-di-ackermann/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Interrogazioni XQuery in Java</title>
		<link>http://www.fireteam.it/2009/08/interrogazioni-xquery-in-java/</link>
		<comments>http://www.fireteam.it/2009/08/interrogazioni-xquery-in-java/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 08:28:25 +0000</pubDate>
		<dc:creator>saverio</dc:creator>
				<category><![CDATA[Programmazione Java]]></category>
		<category><![CDATA[basex]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xquery]]></category>

		<guid isPermaLink="false">http://www.fireteam.it/?p=574</guid>
		<description><![CDATA[XQuery, una abbrevazione per XML Query Language, è un linguaggio di programmazione specificato dal W3C e destinato ad interrogare documenti e basi di dati XML. Questo perché XML si sta proponendo come la tecnologia per rimpiazzare i vecchi DBMS relazionali  
Il w3c ha definito il linguaggio XQuery 1.0; usa la sintassi delle espressioni di [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.fireteam.it/wp-content/uploads/2009/08/xquery.gif"><img class="alignright size-full wp-image-577" title="xquery" src="http://www.fireteam.it/wp-content/uploads/2009/08/xquery.gif" alt="xquery" width="160" height="160" /></a>XQuery, una abbrevazione per XML Query Language, è un linguaggio di programmazione specificato dal W3C e destinato ad interrogare documenti e basi di dati XML. Questo perché XML si sta proponendo come la tecnologia per rimpiazzare i vecchi DBMS relazionali <img src='http://www.fireteam.it/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Il w3c ha definito il linguaggio XQuery 1.0; usa la sintassi delle espressioni di XPath  2.0, con l&#8217;aggiunta delle cosiddette espressioni FLWOR per la formulazione di query complesse. Il risultato è un linguaggio di programmazione funzionale, dichiarativo, con somiglianze con il vecchio SQL.</p>
<p style="text-align: justify;">Per effettuare delle query xquery su un file XML possiamo usare delle librerie come BaseX e Saxon. Purtroppo attualmente Saxon non è un prodotto del tutto gratuito, quindi scegliamo di usare BaseX, un processore Xquery-XPath open source.</p>
<p style="text-align: justify;"><span id="more-574"></span>In realtà BaseX, oltre ad essere utlilizzabile come libreria all&#8217;interno del linguaggio Java, ci mette a disposizione un&#8217;interfaccia grafica dalla quale possiamo effettuare query su file XML ben formati arbitrari.</p>
<h2 style="text-align: justify;">Primo esempio di query</h2>
<p style="text-align: justify;">La prima cosa da fare è inserire i file jar di BaseX nel build path del nostro progetto; la seconda è assicurarsi di avere java 1.6 (non funziona con java 1.5) perché BaseX utilizza il package javax.xml.stream.</p>
<p style="text-align: justify;">Questo è un sempio dove si esegue la query <strong>//li </strong>sul file &#8216;<strong>input</strong>&#8216;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
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="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.xquery.XQConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.xquery.XQDataSource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.xquery.XQPreparedExpression</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.xquery.XQResultSequence</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> XQueryAPIExample <span style="color: #009900;">&#123;</span>
 <span style="color: #008000; font-style: italic; font-weight: bold;">/** Database Driver. */</span>
 <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> DRIVER <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;org.basex.api.xqj.BXQDataSource&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Gets the XQDataSource for the specified Driver.</span>
 XQDataSource source <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>XQDataSource<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span>DRIVER<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Creates an XQConnection</span>
 XQConnection conn <span style="color: #339933;">=</span> source.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Prepares the Expressionwith the Document and the Query.</span>
 XQPreparedExpression expr <span style="color: #339933;">=</span> conn.<span style="color: #006633;">prepareExpression</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;doc('input')//li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Executes the XQuery query.</span>
 XQResultSequence result <span style="color: #339933;">=</span> expr.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Gets all results of the execution.</span>
 <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Prints the results to the console.</span>
 <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">getItemAsString</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Questo esempio funziona solo se il file XML interrogato non dichiara nessun namespace.</p>
<h2 style="text-align: justify;">Query in presenza di namespace</h2>
<p style="text-align: justify;">Supponiamo adesso di interrogare un file XML con namespace&#8230; ad esempio un file in formato XML Mpeg-7 che usa i seguenti namespace:<br />
xmlns=&#8221;urn:mpeg:mpeg7:schema:2001&#8243;<br />
xmlns:mpeg7=&#8221;urn:mpeg:mpeg7:schema:2001&#8243;<br />
xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;</p>
<p style="text-align: justify;">Per far riconoscere i namespace dobbiamo dichiararli nel prologo della xquery in questo modo:<br />
declare default element namespace &#8220;urn:mpeg:mpeg7:schema:2001&#8243;<br />
declare  namespace mpeg7 = &#8220;urn:mpeg:mpeg7:schema:2001&#8243;<br />
declare  namespace xsi = &#8220;http://www.w3.org/2001/XMLSchema-instance&#8221;
</p>
<p style="text-align: justify;">Questo è il codice che esegue la query sul file file/video/extract.xml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> prologoQuery <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">+</span>
 <span style="color: #0000ff;">&quot;declare default element namespace <span style="color: #000099; font-weight: bold;">\&quot;</span>urn:mpeg:mpeg7:schema:2001<span style="color: #000099; font-weight: bold;">\&quot;</span>; &quot;</span> <span style="color: #339933;">+</span>
 <span style="color: #0000ff;">&quot;declare  namespace mpeg7 = <span style="color: #000099; font-weight: bold;">\&quot;</span>urn:mpeg:mpeg7:schema:2001<span style="color: #000099; font-weight: bold;">\&quot;</span>; &quot;</span> <span style="color: #339933;">+</span>
 <span style="color: #0000ff;">&quot;declare  namespace xsi = <span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span style="color: #000099; font-weight: bold;">\&quot;</span>; &quot;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Gets the XQDataSource for the specified Driver.</span>
 XQDataSource source <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>XQDataSource<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span>DRIVER<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Creates an XQConnection</span>
 XQConnection conn <span style="color: #339933;">=</span> source.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Prepares the Expressionwith the Document and the Query.</span>
 <span style="color: #666666; font-style: italic;">//XQPreparedExpression expr = conn.prepareExpression(&quot;&lt;xml&gt;1 + 2 = { 1+2 }&lt;/xml&gt;/text()&quot;);</span>
 <span style="color: #666666; font-style: italic;">//XQPreparedExpression expr = conn.prepareExpression(&quot;doc('file/video/20090201_video_15213221.xml')//meta&quot;);</span>
 XQPreparedExpression expr <span style="color: #339933;">=</span> conn.<span style="color: #006633;">prepareExpression</span><span style="color: #009900;">&#40;</span>prologoQuery <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; doc('file/video/extract.xml')//Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Executes the XQuery query.</span>
 XQResultSequence result <span style="color: #339933;">=</span> expr.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Gets all results of the execution.</span>
 <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">//element = (org.w3c.dom.Element) result.getObject();</span>
 <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">getItemAsString</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Nella riga 18 è commentato un altro modo per usare gli oggetti restiuiti dalla query, che ci restituisce il risultato come elementi della struttura DOM del file XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fireteam.it/2009/08/interrogazioni-xquery-in-java/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Java 1.6 su Mac OS X</title>
		<link>http://www.fireteam.it/2009/08/java-1-6-su-mac-os-x/</link>
		<comments>http://www.fireteam.it/2009/08/java-1-6-su-mac-os-x/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 19:44:56 +0000</pubDate>
		<dc:creator>saverio</dc:creator>
				<category><![CDATA[Programmazione Java]]></category>
		<category><![CDATA[jdk]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.fireteam.it/?p=558</guid>
		<description><![CDATA[Giorni fa stavo lavorando su un progetto java riguardante XML ed XQuery, ed ho avuto questo errore:
&#8220;Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamReader&#8221;
uso Mac Os X 10.4 aggiornato all&#8217;ultima versione di Java supportata da Apple&#8230; perché ho questo errore? Quando si ha:
Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: NomeFile
Probabilmente il file NomeFile.class non viene &#8220;visto&#8221; da Java. Bisogna [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fireteam.it/wp-content/uploads/2009/08/imac_java.jpg"><img class="alignleft size-full wp-image-563" title="imac_java" src="http://www.fireteam.it/wp-content/uploads/2009/08/imac_java.jpg" alt="imac_java" width="384" height="261" /></a>Giorni fa stavo lavorando su un progetto java riguardante XML ed XQuery, ed ho avuto questo errore:</p>
<p>&#8220;Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamReader&#8221;</p>
<p>uso Mac Os X 10.4 aggiornato all&#8217;ultima versione di Java supportata da Apple&#8230; perché ho questo errore? Quando si ha:<br />
Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: NomeFile<br />
Probabilmente il file NomeFile.class non viene &#8220;visto&#8221; da Java. Bisogna verificare se nella directory è contenuto il file NomeFile.class, ma nel mio caso è una classe della JVM (javax.xml.stream.XMLStreamReader)!!!</p>
<p>Il problema è che java 1.5 non ha il package javax.xml.stream.*, ed ho bisogno di fare l&#8217;aggiornamento a java 1.6. Per chi ha Mac Os X 10.5 l&#8217;aggiornamento di java è molto semplice</p>
<p><span id="more-558"></span></p>
<p>per via delle politiche di Apple per la distribuzione delle JVM.</p>
<h2>Java 1.6 su Mac OS X 10.5</h2>
<p>Per prima cosa verifichiamo la nostra versione di java dal Terminale</p>
<pre class="shell">saverio$ java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)</pre>
<p>se abbiamo la versione 1.5.x, allora aggiorniamo il sistema all&#8217;ultima versione cliccando sulla mela e poi &#8216;Aggiornamento software&#8230;&#8217;, e seguiamo la procedura guidata.</p>
<p>Una volta aggiornato il sistema abbiamo java 1.6 installato nella cartella <em>/System/Library/Frameworks/JavaVM.framework/Versions/1.6/</em> , ma non è abilitato di default; infatti quando il sistema chiama java fa riferimento al file <strong>/usr/bin/java</strong> che è un link simbolico alla versione 1.5 di java:</p>
<pre class="shell">saverio$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Apr 30 08:41 /usr/bin/java -&gt; /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java</pre>
<p>Per abilitare java 1.6 cancelliamo (o rinominiamo) il link simbolico con:<br />
<strong>sudo rm /usr/bin/java</strong><br />
e ne creiamo uno nuovo che punta alla nuova versione di java:<br />
<strong>sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java /usr/bin/java</strong></p>
<p>Questa procedura funziona solo con sistemi a 64bit. Per quelli a 32bit bisogna seguire la seguente procedura per Mac OS X 10.4</p>
<h2>Java 1.6 su Mac OS X 10.4</h2>
<p>Installare invece Java 1.6 su Mac OS X 10.4 è leggermente più complicato. Prima di tutto verifichiamo che nel sistema sia installata la versione 1.5</p>
<pre class="shell">saverio$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02-306)
Java HotSpot(TM) Client VM (build 1.5.0_19-138, mixed mode, sharing)</pre>
<p>La versione 1.6 di java per questa piattaforma è un porting di OpenJDK chiamato SoyLatte. Per installarla:</p>
<p>* Scaricare SoyLatte 1.0.2 per Mac OS X 10.4 (oppure 10.5 se stiamo su Mac OS X 10.5 a 32bit) dal sito <a href="http://landonf.bikemonkey.org/static/soylatte/">http://landonf.bikemonkey.org/static/soylatte/</a>. Per scaricarlo si avrà bisogno delle credenziali username: jrl, e password: I am a Licensee in good standing.<br />
* Unzippare il pacchetto in una directory a scelta (si può anche rinominare la directory <em>soylatte16-1.0.2</em>)<br />
* Aggiungere la directory <em>soylatte16-1.0.2/bin</em> al path di sistema $PATH in modo da dargli precedenza rispetto al path della versione 1.5 di java</p>
<p>Per verificare la nuova installazione digitiamo come consueto il comando <strong>java -version</strong>, e se tutto è stato fatto bene allora la versione sarà 1.6</p>
<h2>Java e Mac OS X</h2>
<p>Mac OS X è uno splendido sistema operativo, nettamente superiore rispetto ai suoi concorrenti! Purtroppo ho sempre avuto problemi con le versioni di java supportate da Apple. Se siete dei programmatori java appassionati dei sistemi unix-like, vi consiglio di usare Ubuntu Linux per sviluppare le vostre applicazioni.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fireteam.it/2009/08/java-1-6-su-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
