Mark Phalan and Karol Harezlak

Java ME development with Solaris x86

This tutorial provides information about setting up an environment to use Solaris OS for developing Java ME application using BrandZ (Branded Zones), J2ME Wireless Toolkit 2.2 and Netbeans Mobility Pack 5.5. Branded Zones allow Linux applications to run on Solaris unmodified.

This tutorial demonstrates a method for using NetBeans Mobility Pack on Solaris OS. Currently there is not a native Solaris version of Mobility Pack available.

More information about the technologies used in this tutorial are available on following pages:

  • Solaris Express Developers Edition -
  • Solaris BrandZ -
  • Java Micro Edition -
  • Wireless Toolkit -
  • Netbeans Mobility - mobility
Before we set up our environment, make sure that you have the following applications downloaded on your machine:
  • Java Development Kit 6 with Netbeans 5.5 for Linux
  • Wireless Toolkit 2.2 for Linux
  • Netbeans Mobility 5.5 for Linux
  • CentOS tarball-

Also make sure that BrandZ is installed on your version of Solaris. If you are using Solaris Express Developers Edition, BrandZ is included in the default installation. Other versions of Solaris may need additional steps to install BrandZ.

Step-by-step guide to setting up our Branded Zone. The basic steps are as follows:

  • Set up a private network.
  • Configure an lx branded zone.
    • Assign a network address on the private network
    • Add a filesystem which is a loopback mount of your user's home directory
  • Install the lx zone
  • Configure the lx branded zone
    • Setup networking
    • Create a user with the same uid as your user
  • Setup ssh keys so you can log in to the lx branded zone without using a password
  • Create a small script which allows the running of Linux apps from the global zone

Pre-zone install configuration

Setting up networking in the global zone

This sets up a private network that is used to link the global zone with the branded zone you created. The Linux branded zone will not have external network access. If you want the Linux zone to have access to the external network you need to assign a valid IP address to the branded zone. However once the network goes away, so will access to your branded zone via ssh. This limitation can be worked around, but it is more complex (see here for more info). If you assign a real IP address to the branded zone you can skip this section (also substitute the real IP address for in the following sections).

You can substitute username with any existing unix username you like.

I have an Intel Ethernet card and my network device is iprb0. To found out what network device you are using run the command:

[root@global_zone /]# /sbin/dladm show-link

Use this name in place of iprb0 in the following sections.

[root@global_zone /]# echo "addif up" >> /etc/hostname.iprb0 
[root@global_zone /]# echo "   lhost" >> /etc/hosts 
[root@global_zone /]# echo "   centos" >> /etc/hosts 
[root@global_zone /]# svcadm restart milestone/network

Branded zone installation

Make sure that you have enough disk space to install the zone, you'll probably need about 1.5GB. In the example I install into /data/brands/centos which resides on a ZFS filesystem. You can install the zone wherever you like. If you are using ZFS a filesystem is automatically created for you. Otherwise you may have to create the directory before creating the zone.

During zone configuration a filesystem is added to the branded zone. This filesystem is the home directory of the user mounted loopback into the zone. You should make sure that /export/home/username is the directory where the filesystem is mounted in the global zone. Create the zone

[root@global_zone /]# zonecfg -z centos
centos: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:centos> create -t SUNWlx
zonecfg:centos> set zonepath=/data/brands/centos
zonecfg:centos> set autoboot=true
zonecfg:centos> add net
zonecfg:centos:net> set address=
zonecfg:centos:net> set physical=iprb0
zonecfg:centos:net> end
zonecfg:centos> add attr
zonecfg:centos:attr> set name="audio"
zonecfg:centos:attr> set type=boolean
zonecfg:centos:attr> set value=true
zonecfg:centos:attr> end
zonecfg:centos> add fs
zonecfg:centos:fs> set dir=/home/username
zonecfg:centos:fs> set special=/export/home/username
zonecfg:centos:fs> set type=lofs
zonecfg:centos:fs> end
zonecfg:centos> commit
zonecfg:centos> exit
[root@global_zone /]# 

Install the zone

Download centos_fs_image.tar.bz2 from the brandz webpage. I downloaded it to ~/Desktop/.

[root@global_zone /]# zoneadm -z centos install -d /home/username/Desktop/centos_fs_image.tar.bz2 
A ZFS file system has been created for this zone.
Installing zone 'centos' at root directory '/data/brands/centos'
from archive '/home/username/Desktop/centos_fs_image.tar.bz2'
This process may take several minutes.
Setting up the initial lx brand environment.
System configuration modifications complete.
Setting up the initial lx brand environment.
System configuration modifications complete.
Installation of zone 'centos' completed successfully.
Details saved to log file:
[root@global_zone /]# 

Set the root prompt for the Linux zone

This step is unnecessary but I added it so that it obvious in the following instructions where the commands are being run and by whom.

[root@global_zone /]# cat > /data/brands/centos/root/root/.bash_profile <<EOF
> export PS1="[\u@\h \w]# "
[root@global_zone /]# 

Boot the zone

[root@global_zone /]# zoneadm -z centos boot

Login and setup

In this section a new user is set up with the same uid as the user in the global zone. In order to determine the uid of the local user run the command:

[username@global_zone ~]$ id 
4. Update opensolaris webpage. [done]
[root@global_zone /]# zlogin centos
[Connected to zone 'centos' pts/6]
Welcome to your shiny new Linux zone.
        - The root password is 'root'.  Please change it immediately.
        - To enable networking goodness, see /etc/sysconfig/network.example.
        - This message is in /etc/motd.  Feel free to change it.
For anything more complicated, see:
You have mail.
[root@centos ~]# useradd -u uid -M -d /home/username username
[root@centos ~]# passwd username 
Changing password for user username.
New UNIX password: 
Retype new UNIX password: 
passwd: all authentication tokens updated successfully.
[root@centos ~]# printf '   centos\n' >> /etc/hosts
[root@centos ~]# printf 'NETWORKING="yes"\n' > /etc/sysconfig/network
[root@centos ~]# printf 'HOSTNAME=centos\n' >> /etc/sysconfig/network
[root@centos ~]# cat /etc/hosts
[root@centos ~]# init 6
[root@centos ~]#

Set up ssh keys

ssh is used to provide seamless access to the zone, as it provides X forwarding X applications can be run easily. By using keys a password is no longer required to access the zone. The passphrase was left blank in the example below. (A passphrase can be used but it makes things slightly more complicated - see ssh-agent(1)).

[username@global_zone ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/
The key fingerprint is:
32:f8:1c:e6:c1:ab:90:11:21:55:88:9d:94:d7:e6:c2 username@global_zone
[username@global_zone ~]$ cp .ssh/ .ssh/authorized_keys 
[username@global_zone ~]$

Set up the lrun script

[username@global_zone ~]$ cat > lrun
> #!/bin/ksh
> exec ssh -X centos "$@"
[username@global_zone ~]$ chmod +x lrun
[username@global_zone ~]$ mkdir ~/bin
[username@global_zone ~]$ mv lrun ~/bin
[username@global_zone ~]$ export PATH=$PATH:/home/username/bin

You may want to add "PATH=$PATH:/home/username/bin" to your shell rc file. Install Netbeans in the branded zone

[username@global_zone ~]$ chmod +x ~/Desktop/jdk-6-nb-5_5-linux.bin 
[username@global_zone ~]$ lrun ~/Desktop/jdk-1_5_0_10-nb-5_5-linux.bin
The authenticity of host 'centos (' can't be established.
RSA key fingerprint is be:49:a8:09:8c:19:18:cc:f2:1c:e3:84:c7:76:d7:5d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'centos,' (RSA) to the list of known hosts.

Install Netbeans Mobility Pack and Wirless Toolkit

To install NetBeans Mobility Pack 5.5 type:

[username@global_zone ~]$ lrun JAVA_HOME=~/jdk1.6.0 ~/Desktop/netbeans-mobility-5_5-linux.bin 

Answer all the questions as usual, choose the default location to install.

(Optional, some version of Mobility Pack comes with Wirless Toolkit) There is two possible ways how to install Wireless Toolkit:

1) Using command line

[username@global_zone ~]$ lrun JAVA_HOME=~/jdk1.6.0 ~/j2me_wireless_toolkit-2_2-linux-i386.bin

2) Using Netbeans Update Center Answer all the questions as usual, choose the default location to install. If your branded zone has access to the internet it is possible to install some version of WTK directly from IDE using Netbeans Update Center.

Entry/Inline Property Editor

After installation don't forget to add new Java Micro Edition Platform Emulator using Java Platform Manager (menu: Tools>Java Platform Manager)

You can find more information about how to use Mobility Pack and add new Java Micro Edition Platform Emulator reading this tutorial:

Launch NetBeans

[username@global_zone ~]$ sed -e 's#Exec=.*#Exec=lrun ~/netbeans-5.5/bin/netbeans#' ~/Desktop/netbeans5.5.desktop > /tmp/netbeans5.5.desktop
[username@global_zone ~]$ mv /tmp/netbeans5.5.desktop ~/Desktop/netbeans5.5.desktop

Double-click on the NetBeans icon on your desktop to launch NetBeans! Any linux program in your home directory can be run as follows:

[username@global_zone ~]$ lrun <linux_program>

Contact with authors:

Mark Phalan: (Solaris organization)
Karol Harezlak: (NetBeans organization)

-- KarolHarezlak - 19 Feb


mobility_on_solaris_small.png Info on mobility_on_solaris_small.png 233572 bytes
upadate1.png Info on upadate1.png 26953 bytes


Referenced by: