All Boards Java

Document created by jesseg Employee on Aug 15, 2012Last modified by grantw on Mar 22, 2013
Version 2Show Document
  • View in full screen mode

JAVA on i.MX

Sun Microsystems has pre-built versions of Java Virtual Machine for ARM Processors. It's possible to download them at: http://java.sun.com/javase/downloads/embedded.jsp

 

 

All pre-built software mentioned on site above are distributed as evaluation software. For more information about use and license, please contact Sun Microsystems

 

 

i.MX31 PDK will be used as an example to describe installation, compilation and execution procedures. It can be easily done for other i.MX platforms

 

 

Installing Sun Java on i.MX

For i.MX31, i.MX35, download the following version:

UsageHeadfulBinary Version
Non-Graphical ApplicationsARMv6 Linux - Headless (Early Access)EABI, glibc 2.5, Hard Float (VFP), Little Endian
Graphical ApplicationsARMv6 Linux - Headful (Early Access)EABI, glibc 2.5, Hard Float (VFP), Little Endian

 

For i.MX21, i.MX25, i.MX27, download the following version:

UsageHeadfulBinary Version
Non-Graphical ApplicationsARMv5 Linux - Headless (Early Access)EABI, glibc 2.5, Soft Float, Little Endian
Graphical ApplicationsARMv5 Linux - Headful (Early Access)EABI, glibc 2.5, Soft Float, Little Endian

 

On following example, a graphical application will be compiled, the headful version will be used.

 

 

This example uses X11 as graphical server. On LTIB, select X11 and also the package libXtst and libXi.

 

 

Extract the downloaded package (in this case "ejre-1_6_0_10-ea-b39-linux-armv6-vfp-eabi-min-eval-30_jul_2009.tar.gz")

tar xzvf ejre-1_6_0_10-ea-b39-linux-armv6-vfp-eabi-min-eval-30_jul_2009.tar.gz 

Create a new folder on <LTIB Directory>/rootfs/ called ejre1.6.0_10

cd rootfs sudo mkdir ejre1.6.0_10 

Copy all files and folders located inside the extracted package to <LTIB Directory>/rootfs/ejre1.6.0_10/

cd rootfs/ejre1.6.0_10 
cp -a ../../ejre1.6.0_10/* .

Include the bin folder to the PATH:

export PATH=$PATH:/ejre1.6.0_10/bin/ 

In this example the X11 will be used as graphical server. Add the display environment variable:

export DISPLAY=:0 

Running a simple program

Compiling and testing on Host PC

Let's first compile and test a simple program on Host Machine (PC).

Create a file called Example1.java and add the following code:

import java.awt.*;
  
public class Example1 extends java.applet.Applet 
{
   public void init() 
   { 
        add(new Button("One")); 
        add(new Button("Two")); 
   }  

   public Dimension preferredSize() 
   { 
        return new Dimension(480, 640); 
   }  
   
   public static void main(String [] args) 
   { 
        Frame f = new Frame("Example 1");  

        Example1 ex = new Example1();  

        ex.init();  

        f.add("Center", ex);  
        
        f.pack(); 
        f.show(); 
   } 
} 

On terminal, compile the source code using ecj:

$ ecj Example1.java 

 

 

ecj Java Compiler is needed to compile this example. To install ecj on Debian based OS, install the packages: sudo apt-get install ecj ecj-gcj libecj-java libecj-java-gcj

 

 

Now it's possible to test the compiled program. Just type on host:

$ java Example1 

The following window will be shown:

240px-Java1_pc.png

 

Running on i.MX

Copy the file Example1.class to <LTIB Directory>/rootfs/home

cp Example1.class rootfs/home 

On i.MX Linux, start Xfbdev in background:

$ Xfbdev & 

Run Example1:

$ java Example1 

The following screen will be shown on LCD:

240px-Java1_pdk31.png



1 person found this helpful

Attachments

    Outcomes