Tuesday, June 09, 2015

How to create embedded Java 8

What is embedded java? Embedded Java is not J2ME (Java Micro Edition), is a normal java runtime in smaller size, suitable to be installed in embedded system.

Normal Java runtime is about 80-100Mb in size. The compact embedded java can be as small as 11Mb.

Started with Java 8 (or 1.8), Java use jrecreate to generate embedded java for specific target platform. The targeting platform is for ARM Linux and x86 Linux. It can be generated on a host with Linux or Windows (prefer to have 1Gb or memory?).

My target platform is DNS-320 with fun_plug hack. It is an ARM cpu (ARMv5TE with soft floating point), 128Mb ram (Yes, is 128Mb). You can create target for Raspberry Pi (with hard floating point).

You need a Java (JDK or JRE) on the host system. After generated, you can just move over the embedded JRE to the target platform.

Download Embedded Java from Oracle technical network.

For my case here, I use:

Embedded Java 1.8, ARM v5 with soft floating point (ejdk-8u33-fcs-linux-arm-sflt.gz).
OpenJDK 1.7 on Debian (32-bits), and build it on Debian 7 runs on Virtualbox VM (on Mac OS X).

Debian$ sudo apt-get install openjdk-7-jre

Extract embedded java 1.8

Debian $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
Debian $ export EJDK=<target directory>
Debian $ cd ejdk1.8.0_33
Debian ejdk1.8.0_33 $ bin/jrecreate.sh --profile compact1 --dest compact1-minimal --vm minimal
Building JRE using Options {
target: linux_arm_sflt
vm: minimal
runtime: compact1 profile
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: []

Target JRE Size is 10,837 KB (on disk usage may be greater).
Embedded JRE created successfully

The size is 11Mb.

Debian$ du -sh compact1-minimal/.
11M compact1-minimal/.

I write a HelloWorld java to test.

$ cat > HelloWorld.java <<-EOF

public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");

$ gcc HelloWorld.java
⇒ HelloWorld.class
$ java HelloWorld
Hello, world!

I move the hello world program and compact1-minimal to my target platform (the ARM Linux) /opt/java/ejre-1.8.

arm$ export JAVA_HOME=/opt/java/ejre-1.8
arm$ export PATH=$JAVA_HOME/bin:$PATH

arm$ file HelloWorld.class
HelloWorld.class: compiled Java class data, version 49.0 (Java 1.5)

arm$ java -version
java version "1.8.0_33"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_33-b05, profile compact1, headless)
Java HotSpot(TM) Embedded Minimal VM (build 25.33-b05, mixed mode)

arm$ java HelloWorld
Hello, world!

Now you can create an embedded java 8 for Raspberry Pi.

Sunday, May 03, 2015

Touch'n Go Dormant Card Issue

A few years back Touch'n Go given out a lot of free cards to the public, as a promotion of the Touch'n Go card, now they changed their strategy.

If your Touch'n Go card has not been used and top up for more than 12 months time, the card will be dormant (or suspended). Once the card has been dormant, you are not able to activate the card, the remaining amount can be claimed. Touch'n Go company will charge you RM5 as the processing fees, and it takes months time to get back the money.

The reason given by the company why they need to deactivate the unused card because their server performance is affected by those unused cards.

  1. Why TNGSB needs to deactivate dormant card?
    1. There is quite a number of dormant or inactive Touch 'n Go cards in our system. These dormant cards have caused unnecessary load that prevent the system from operating optimally, thus affecting our service level to all active users. By deactivating these non-active cards, we will be able to streamline our system to improve system efficiency and to provide good services to all our customers.
By today's standard, a few millions cards is not really a big issue for server processing. If the company can not handle the few millions cards, do you think they can handle millions of dollars?

If you compare the smart card policy with other Asian countries like Singapore, Hong Kong, Taiwan or even China. All smart card in these countries can be activated easily, even you have stop using it for more than 12 months time.

Is not all bad move done by Touch'n Go company. They have done something better as well. They have migrated to a new web system. The old e-statement website is not working anymore. You need to register again with the new website (https://tngportal.touchngo.com.my/), you can only manage 1 card with the original website, but now you can manage more cards with the new website.

I don't think server processing is an issue. As a promotion for the Touch'n Go card, the card should be able to be reactivated as needed. This is just a policy issue for a lame reason.

Friday, April 10, 2015

My 2 cents on Apple Watch 2015

Apple is going to offer it's first smart watch, Apple Watch for their employee at 50 percent discount. May be Apple don't expect the Apple Watch sell very good in the market.

I am not too worried about the sales figure, Apple always has a group of fans and buyers. Let's wait till the next Apple event for the sales report.

I am going to talk about 2 things that I feel not right for Apple Watch.

I do not have an Apple Watch to try out, I just base on what I saw on the web.

1. Target Audience

Apple designer Jonathan Ive claimed that, "The Swiss watch industry is in trouble." (read here). Look at Apple Watch price range from USD400 to USD15,000 (here).

For lower price range Apple Watch, it may affected those quartz and electronic watch, especially those with some sport features like Suunto, Casio etc.

For the high price market, Apple has Apple Watch Edition series which cost more than USD10k. Since most people are not going to wear 2 watches at the same time, I don't think they will dumped their Rolex watch for Apple smart watch.

For a smart watch with additional function, the older smart watch will be outdated very soon, after Apple came out with new hardware and software.

2. The Watch Face

For me, the watch face is the biggest design flaw. The watch face must be round, not other shape. There are square, rectangle or diamond shape watches out there, but majority are still round in shape.

The moto360 looks like a better design in this category.


Apple Watch could be a fashion, but it will not be a classic, for now.

Apple to offer Watch to employees at half price, CNet

Sunday, April 05, 2015

A college math professor's April Fool prank 2015

How could I miss this. A math and computer science professor, Matthew Weathers make a video prank in his math class.

↵ Use original player
← Replay

YouTube here.

This is not his first time prank in his class.

Who says no one has humor in computer science?

Friday, April 03, 2015

The New MacBook 2015

The new MacBook 2015 is not a MacBook Air or a MacBook Pro, it is 12-inch notebook, with retina display, it is even lighter than MacBook Air.

There are a few things you may need to know about the new MacBook:

1. Retina Display

12-inch retina display, with resolution 2304x1440. Is about 225 dpi.

2. Fanless

The new MacBook has no fan. It is just 5 watt power, really low power, that's why it doesn't need a fan.

3. Only 1 Adapter Interface

There is only 1 adapter, USB-C for charging, input and output. So you can't plug in the external storage and charge the notebook together, but you can get an external adapter, just pay more.

4. Other

The keyboard. Apple change the keyboard design from traditional scissor mechanism to butterfly mechanism. According to Apple, for older keyboard design, you need to hit the centre of the keyboard button, the new butterfly mechanism keyboard is more stable and more responsive.

5. The Apple Logo

The luminous Apple logo was replaced by a chromed Apple Logo. This is the least important, but this is not so “Apple-style” or “Job’s style".