
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://armadeus.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NicolasPa</id>
		<title>ArmadeusWiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://armadeus.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NicolasPa"/>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Special:Contributions/NicolasPa"/>
		<updated>2026-04-04T06:26:38Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10014</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10014"/>
				<updated>2011-09-08T21:17:30Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Java programs and native libraries==&lt;br /&gt;
&lt;br /&gt;
The use of native libraries can be required when plateform-specific features are needed. In such a context, Java Native Interface (JNI) is helpful. This framework is included in the jamvm package but another tool called SWIG (Simplified Wrapper and Interface Generator) facilitates the design of this interface.&lt;br /&gt;
SWIG can be installed in debian/ubuntu linux distributions as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install swig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, an example can be easily tested. For instance, the one proposed in the tutorial submenu of the SWIG website is based on a single example.c file (and an associated interface file example.i similar to a header file .h). The key function of this library&lt;br /&gt;
is char * get_time() because it is based on a system-based library (header file time.h).&lt;br /&gt;
Use the following commands to produce the required files (native library libexample.so and static class example.class) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
swig -java example.c example.i&lt;br /&gt;
arm-linux-gcc -fpic -c example.c example_wrap.c&lt;br /&gt;
arm-linux-gcc -shared example.o example_wrap.o -o libexample.so&lt;br /&gt;
cat test.java&lt;br /&gt;
 public class test {&lt;br /&gt;
   public static void main(String argv[]) {&lt;br /&gt;
     System.loadLibrary(&amp;quot;example&amp;quot;);&lt;br /&gt;
     System.out.println(example.getMy_variable());&lt;br /&gt;
     System.out.println(example.fact(5));&lt;br /&gt;
     System.out.println(example.get_time());&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
javac test.java&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warning| The name of the java test class is &amp;quot;main&amp;quot; in the SWIG tutorial but &amp;quot;test&amp;quot; is preferred here due to the ambiguity between the name of the class and the name of the main function.}}&lt;br /&gt;
&lt;br /&gt;
Then, three files (libexample.so, example.class, exampleJNI.class and test.class) must be downloaded into the APF board. They can be placed in the tftp server directory (e.g. /tftpboot) and then downloaded as follows (with the correct XXX.XXX.XXX.XXX IP address)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
tftp -g -r libexample.so XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r example.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r exampleJNI.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r test.class XXX.XXX.XXX.XXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verifiy (and change if necessary) privileges of these files. Then run the test class&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -Djava.library.path=$LD_LIBRARY_PATH test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where $LD_LIBRARY_PATH is the path of the directory where libexample.so is located in (e.g. /root).&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;br /&gt;
* [http://www.swig.org/ SWIG website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10013</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10013"/>
				<updated>2011-09-08T21:14:17Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Java programs and native libraries==&lt;br /&gt;
&lt;br /&gt;
The use of native libraries can be required when plateform-specific features are needed. In such a context, Java Native Interface (JNI) is helpful. It is included in the jamvm package but another tool called SWIG (Simplified Wrapper and Interface Generator) facilitates the design of this interface.&lt;br /&gt;
SWIG can be installed in debian/ubuntu linux distributions as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install swig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, an example can be easily tested. For instance, the one proposed in the tutorial submenu of the SWIG website is based on a single example.c file (and an associated interface file example.i similar to a header file .h). The key function of this library&lt;br /&gt;
is char * get_time() because it is based on a system-based library (header file time.h).&lt;br /&gt;
Use the following commands to produce the required files (native library libexample.so and static class example.class) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
swig -java example.c example.i&lt;br /&gt;
arm-linux-gcc -fpic -c example.c example_wrap.c&lt;br /&gt;
arm-linux-gcc -shared example.o example_wrap.o -o libexample.so&lt;br /&gt;
cat test.java&lt;br /&gt;
 public class test {&lt;br /&gt;
   public static void main(String argv[]) {&lt;br /&gt;
     System.loadLibrary(&amp;quot;example&amp;quot;);&lt;br /&gt;
     System.out.println(example.getMy_variable());&lt;br /&gt;
     System.out.println(example.fact(5));&lt;br /&gt;
     System.out.println(example.get_time());&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
javac test.java&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warning| The name of the java test class is &amp;quot;main&amp;quot; in the SWIG tutorial but &amp;quot;test&amp;quot; is preferred here due to the ambiguity between the name of the class and the name of the main function.}}&lt;br /&gt;
&lt;br /&gt;
Then, three files (libexample.so, example.class, exampleJNI.class and test.class) must be downloaded into the APF board. They can be placed in the tftp server directory (e.g. /tftpboot) and then downloaded as follows (with the correct XXX.XXX.XXX.XXX IP address)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
tftp -g -r libexample.so XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r example.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r exampleJNI.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r test.class XXX.XXX.XXX.XXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verifiy (and change if necessary) privileges of these files. Then run the test class&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -Djava.library.path=$LD_LIBRARY_PATH test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where $LD_LIBRARY_PATH is the path of the directory where libexample.so is located in (e.g. /root).&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;br /&gt;
* [http://www.swig.org/ SWIG website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10012</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10012"/>
				<updated>2011-09-08T21:13:10Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Java programs and native libraries==&lt;br /&gt;
&lt;br /&gt;
The use of native libraries can be required when plateform-specific features are needed. In such a context, Java Native Interface (JNI) is helpful. It is included in the jamvm package but another tool called SWIG (Simplified Wrapper and Interface Generator) facilitates the design of this interface.&lt;br /&gt;
SWIG can be installed in debian/ubuntu linux distributions as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install swig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, an example can be easily tested. For instance, the one proposed in the tutorial submenu of the SWIG website is based on a single example.c file (and an associated interface file example.i similar to a header file .h). The key function of this library&lt;br /&gt;
is char * get_time() because it is based on a system-based library (header file time.h).&lt;br /&gt;
Use the following commands to produce the required files (native library libexample.so and static class example.class) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
swig -java example.c example.i&lt;br /&gt;
arm-linux-gcc -fpic -c example.c example_wrap.c&lt;br /&gt;
arm-linux-gcc -shared example.o example_wrap.o -o libexample.so&lt;br /&gt;
cat test.java&lt;br /&gt;
 public class test {&lt;br /&gt;
   public static void main(String argv[]) {&lt;br /&gt;
     System.loadLibrary(&amp;quot;example&amp;quot;);&lt;br /&gt;
     System.out.println(example.getMy_variable());&lt;br /&gt;
     System.out.println(example.fact(5));&lt;br /&gt;
     System.out.println(example.get_time());&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
javac test.java&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warning| The name of the java test class is &amp;quot;main&amp;quot; in the SWIG tutorial but &amp;quot;test&amp;quot; is preferred here due to the ambiguity between the name of the class and the name of the main function.}}&lt;br /&gt;
&lt;br /&gt;
Then, three files (libexample.so, example.class, exampleJNI.class and test.class) must be downloaded into the APF board. They can be placed in the tftp server directory (e.g. /tftpboot) and then downloaded as follows (with the correct XXX.XXX.XXX.XXX IP address)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
tftp -g -r libexample.so XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r example.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r exampleJNI.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r test.class XXX.XXX.XXX.XXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verifiy (and change if necessary) privileges of these files. Then run the test class as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -Djava.library.path=$LD_LIBRARY_PATH test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where $LD_LIBRARY_PATH is the path of the directory where libexample.so is located in (e.g. /root).&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;br /&gt;
* [http://www.swig.org/ SWIG website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10011</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10011"/>
				<updated>2011-09-08T21:10:54Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Coupling a java program with native libraries==&lt;br /&gt;
&lt;br /&gt;
The use of native libraries can be required when plateform-specific features are needed. In such a context, Java Native Interface (JNI) is helpful. It is included in the jamvm package but another tool called SWIG (Simplified Wrapper and Interface Generator) facilitates the design of this interface.&lt;br /&gt;
SWIG can be installed in debian/ubuntu linux distributions as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install swig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, an example can be easily tested. For instance, the one proposed in the tutorial submenu of the SWIG website is based on a single example.c file (and an associated interface file example.i similar to a header file .h). The key function of this library&lt;br /&gt;
is char * get_time() because it is based on a system-based library (header file time.h).&lt;br /&gt;
Use the following commands to produce the required files (native library libexample.so and static class example.class) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
swig -java example.c example.i&lt;br /&gt;
arm-linux-gcc -fpic -c example.c example_wrap.c&lt;br /&gt;
arm-linux-gcc -shared example.o example_wrap.o -o libexample.so&lt;br /&gt;
cat test.java&lt;br /&gt;
 public class test {&lt;br /&gt;
   public static void main(String argv[]) {&lt;br /&gt;
     System.loadLibrary(&amp;quot;example&amp;quot;);&lt;br /&gt;
     System.out.println(example.getMy_variable());&lt;br /&gt;
     System.out.println(example.fact(5));&lt;br /&gt;
     System.out.println(example.get_time());&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
javac test.java&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warning| The name of the java test class is &amp;quot;main&amp;quot; in the SWIG tutorial but &amp;quot;test&amp;quot; is preferred here due to the ambiguity between the name of the class and the name of the main function.}}&lt;br /&gt;
&lt;br /&gt;
Then, three files (libexample.so, example.class, exampleJNI.class and test.class) must be downloaded into the APF board. They can be placed in the tftp server directory (e.g. /tftpboot) and then downloaded as follows (with the correct XXX.XXX.XXX.XXX IP address)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
tftp -g -r libexample.so XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r example.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r exampleJNI.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r test.class XXX.XXX.XXX.XXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verifiy (and change if necessary) privileges of these files. Then run the test class as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -Djava.library.path=$LD_LIBRARY_PATH test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where $LD_LIBRARY_PATH is the path of the directory where libexample.so is located in (e.g. /root).&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;br /&gt;
* [http://www.swig.org/ SWIG website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10010</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10010"/>
				<updated>2011-09-08T21:09:11Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Coupling a java program with native libraries==&lt;br /&gt;
&lt;br /&gt;
The use of native libraries can be required when plateform-specific features are needed. In such a context, Java Native Interface (JNI) is helpful. It is included in the jamvm package but another tool called SWIG (Simplified Wrapper and Interface Generator) facilitate the design of this interface.&lt;br /&gt;
SWIG can be installed in debian/ubuntu linux distributions as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install swig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, an example can be easily tested. For instance, the one proposed in the tutorial submenu of the SWIG website is based on a single example.c file (and an associated interface file example.i similar to a header file .h). The key function of this library&lt;br /&gt;
is char * get_time() because it is based on a system-based library (header file time.h).&lt;br /&gt;
Use the following commands to produce the required files (native library libexample.so and static class example.class) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
swig -java example.c example.i&lt;br /&gt;
arm-linux-gcc -fpic -c example.c example_wrap.c&lt;br /&gt;
arm-linux-gcc -shared example.o example_wrap.o -o libexample.so&lt;br /&gt;
cat test.java&lt;br /&gt;
 public class test {&lt;br /&gt;
   public static void main(String argv[]) {&lt;br /&gt;
     System.loadLibrary(&amp;quot;example&amp;quot;);&lt;br /&gt;
     System.out.println(example.getMy_variable());&lt;br /&gt;
     System.out.println(example.fact(5));&lt;br /&gt;
     System.out.println(example.get_time());&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
javac test.java&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Warning| The name of the java test class is &amp;quot;main&amp;quot; in the SWIG tutorial but &amp;quot;test&amp;quot; is preferred here due to the ambiguity between the name of the class and the name of the main function.}}&lt;br /&gt;
&lt;br /&gt;
Then, three files (libexample.so, example.class, exampleJNI.class and test.class) must be downloaded into the APF board. They can be placed in the tftp server directory (e.g. /tftpboot) and then downloaded as follows (with the correct XXX.XXX.XXX.XXX IP address)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
tftp -g -r libexample.so XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r example.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r exampleJNI.class XXX.XXX.XXX.XXX&lt;br /&gt;
tftp -g -r test.class XXX.XXX.XXX.XXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verifiy (and change if necessary) privileges of these files. Then run the test class as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -Djava.library.path=$LD_LIBRARY_PATH test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where $LD_LIBRARY_PATH is the path of the directory where libexample.so is located in (e.g. /root).&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;br /&gt;
* [http://www.swig.org/ SWIG website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	<entry>
		<id>http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10009</id>
		<title>Java package</title>
		<link rel="alternate" type="text/html" href="http://armadeus.org/wiki/index.php?title=Java_package&amp;diff=10009"/>
				<updated>2011-09-08T20:18:45Z</updated>
		
		<summary type="html">&lt;p&gt;NicolasPa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How-To install java on the target and run a java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Install java packages GNU Classpath and JamVM==&lt;br /&gt;
&lt;br /&gt;
Add the GNU Classpath and JamVM to your target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;host&amp;quot;&amp;gt;&lt;br /&gt;
 $ make menuconfig   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Goto the buildroot packages and enable the Java package and from the java sub menu select both GNU classpath and JamVM packages.&lt;br /&gt;
You have to rebuild a new rootfs et update your target&lt;br /&gt;
&lt;br /&gt;
{{Warning| If your java sub menu is empty then you have to select it first from the upper menu.}}&lt;br /&gt;
&lt;br /&gt;
{{Warning| With releases after 3.4 of armadeus you have to activate the Classpath library first (packages-&amp;gt;Libraries-&amp;gt;Java-&amp;gt;classpath) then Jamvm itself (packages-&amp;gt;Interpreter languages..-&amp;gt;jamvm)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Run a java program==&lt;br /&gt;
&lt;br /&gt;
You can run your java program compiled for your host.&lt;br /&gt;
Upload your jar, zip or class files to the target then use the jamvm command to run your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;apf&amp;quot;&amp;gt;&lt;br /&gt;
jamvm -jar myprog.jar&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If your program requires some other libraries, you will have to install these on the target first or build your program to provide your code and these libraries.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* [http://jamvm.sourceforge.net/ JamVM website]&lt;br /&gt;
* [http://www.gnu.org/software/classpath/l GNU Classpath website]&lt;/div&gt;</summary>
		<author><name>NicolasPa</name></author>	</entry>

	</feed>