Archive

Archive for the ‘Java’ Category

Trailer: Java 4ever

June 26th, 2010 No comments

In genius trailer! The .NET vs Java train left the station so long ago for me. .NET’s great for somethings, for everything else, there’s Java. Probably one of the best nerdy videos for the year!

UPDATED: First video was removed ūüôĀ

{lang: 'en-GB'}
Share

Multi-tasking in style on the Android Platform

May 2nd, 2010 No comments

An interesting article posted on the Android Developer Blog from Dianne Hackborn (born to hack!) who discusses the way multi-tasking works on Android. Recommended reading as it goes beyond how it works (and why!) and offers some suggestions on how to make the most of it!

{lang: 'en-GB'}
Share

Ubuntu 10.04 and getting Sun JRE instead of OpenJDK

May 2nd, 2010 1 comment

If you’ve downloaded the latest Ubuntu 10.04 Lucid Lynx you’d realise that they ship with the OpenJDK instead of the Sun (Oracle) JRE. The Ubuntu team has decided to move the Sun Java bits to the partner repository which means we need to do a couple of things prior to getting it through apt-get.
First add the repository to your /etc/apt/sources.list via the add-apt-repository command, then do a full update.

$ add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ apt-get update

Then lets install the Sun JRE & JDK as required.

$ apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
$ apt-get install sun-java6-jdk

Once installed you can verify the correct JRE is installed with:

$ java -version

I have to say, this release of Ubuntu is incredibly refreshing ūüôā Its matured so well in a short period of time, its definitely got the Lynx Effect(NSFW).

{lang: 'en-GB'}
Share

The move to Android from WinMo and Android 2.2 (aka Froyo) coming soon!

April 26th, 2010 1 comment

I switched from using Windows Mobile Phone devices to the Android platform a couple of months back with the Google Nexus One. With Microsoft following the lead of Apple in closing everything they’ve kept open for so long, there wasn’t much to look forward to with Windows Phone 7 (I was almost going to work on that team had I moved to the US a couple of years ago). Though, I’ve started writing for the new WP7 series via work, I’ve felt it was time to move on. Android is a breath of fresh air, I’ve toyed around with the G1 but the Nexus (whilst still a HTC device) is a joy to use as is the operating system. I actually have two Nexus’s these days, one is kept stock as my primary phone, whilst the other is using the Cyanogen mod.

Windows Mobile was never touch friendly – and rightfully so, as the operating system was written for stylus usage as a primary goal,¬† then later HTC (via TouchFlo3D) bolted on a new UI to bring touch friendly UI candy for Windows Mobile. Though Windows Phone 7 brings this to the table (with touch being a primary design goal), I’m ashamed to say they’ve taken what WinMo was good for – being easy to customise and cook ROMs for and turned it to the Apple-esque closed ecosystem and Jobs likes being in control of his herd.

The great thing about the Android is that its got potential and its constant source of updates are very welcome (probably the fastest growth for a platform thus far!), the AppStore has increased exponentially the past few months (which is good and bad – useless app count increases) as users begin to crawl out of the rotting Apples and the stained Windows phones. Another key is that all your Google services are integrated nicely. I’ve given up most of my daily things to Google – email, calendar, contacts… They’re all “in the cloud” and (for now) synchronisable and safe (not that you couldn’t do this with the iPhone or Windows Mobile).

The next release of Android (2.2) is dubbed Froyo and brings some very funky new updates.

JIT Compiler

Probably the biggest addition in this release but first and foremost, the design and architecture of the Android platform is a bit different to others. Forgetting the native development paradigm for Android, you write applications utilising the Java language.

From the Android Developer Guide:

Android applications are written in the Java programming language. The compiled Java code ‚ÄĒ along with any data and resource files required by the application ‚ÄĒ is bundled by the aapt tool into an Android package, an archive file marked by an .apk suffix. This file is the vehicle for distributing the application and installing it on mobile devices; it’s the file users download to their devices. All the code in a single .apk file is considered to be one application.

In many ways, each Android application lives in its own world:

  • By default, every application runs in its own Linux process. Android starts the process when any of the application’s code needs to be executed, and shuts down the process when it’s no longer needed and system resources are required by other applications.
  • Each process has its own virtual machine (VM), so application code runs in isolation from the code of all other applications.
  • By default, each application is assigned a unique Linux user ID. Permissions are set so that the application’s files are visible only that user, only to the application itself ‚ÄĒ although there are ways to export them to other applications as well.

It’s possible to arrange for two applications to share the same user ID, in which case they will be able to see each other’s files. To conserve system resources, applications with the same ID can also arrange to run in the same Linux process, sharing the same VM.

In order to achieve this, the Android platform uses the Dalvik Virtual Machine (which is register based as opposed to the more common stack based machines) suited for embedded devices Рlow memory footprint, run multiple VMs by offloading the process isolation, memory, threading and IO management to the operating system (Android).

The caveat with the Dalvik VM is that the performance is not ideal (it has no JIT compiler) and (by the looks of it) needs to improve garbage collection process (fragmentation is a concern currently). If you’re keen on understanding more about the Dalvik VM, checkout a talk from 2008’s Google I/O about Davik VM Internals (1:01:34). They also realise the performance implications of the runtime.

However, back in November 2009, Bill Buzbee commited the Dalvik JIT code to the Android platform bringing JIT compilation which (if you’ve been using any of the CyanogenMod’s lately) makes a very noticeable and welcome performance boost to all applications.

The (trace-based JIT) compiler detects frequently executed traces (hot paths & loops) and emits optimised code for the platform as necessary, ensuring that minimal heap memory is utilised without the use of any persistence storage Рwhich is what you want in an mobile device!  Trace based JIT compilers are very common today, the TraceMonkey engine in Firefox is an example where dynamic languages (like Javascript) have had a boost through their use. Take a look at SPUR which is a Microsoft research project to bring trace-based JIT Compiler for CIL.

Whilst included in Android 2 it was never enabled, and by the looks of it, Android 2.2 will see this being enabled and stable ūüôā

Linux Kernel update 2.6.32

The upgrade from 2.6.29 to 2.6.32 should bring a trimmed memory foot print and some performance tweaks as well as 802.11n support on devices such as the Google Nexus (yay!)

Flash 10.1 Support

There’s lots of hoo-haa about Flash support on iP*’s and other devices, I’m not too concerned about having it on my phone (less annoying ads browsing the interwebs) but it seems Google will bring Adobe Flash 10.1 support to Android. For some, it was a deal breaker when it came for choosing a phone. I guess now its a matter of ooh-ah!

Automatic application updates

Currently, updating Android applications is quite tedious – updating one application at a time, but it seems a newer update will automatically ensure that your applications are up to date – which is good and bad, I’d like to control when and where it decides to eat up my 3G data for updates (Eg. Update when on wireless)

Hopefully a rollback feature will also be implemented in case the newer versions break things.

Other updates

  • OpenGL ES 2.0 enhancements which game developers will find enticing.
  • The ability to control the color of the trackball (which currently flashes white)
  • Enabling of FM Radio
  • Fixes for resolution and “crazy screen” woes.

When will we be getting this? No-one knows, but suggestions are around the time for the Google I/O event on May 19th.

Next up, I’ll write about some of the applications that I’ve come to use daily, in the meantime you can see the apps running on my Android by checking my AppBrain account. Later some development articles on Android too ūüôā

{lang: 'en-GB'}
Share

Google shows the power of HTML 5, ports Quake II to run in browser!

April 3rd, 2010 No comments

The title says it all. Using the Jake2 port of Quake II (to Java) the bright sparks at Google have used GWT to bring Quake II to HTML 5.

We started with the existing Jake2 Java port of the Quake II engine, then used the Google Web Toolkit (along with WebGL, WebSockets, and a lot of refactoring) to cross-compile it into Javascript. You can see the results in the video above ‚ÄĒ we were honestly a bit surprised when we saw it pushing over 30 frames per second on our laptops (your mileage may vary)!

At first I thought it was an April fools joke, but as cruel as that may be, it wasn’t. Download the source and give it ago, I nearly fell of my chair.

At the moment you have to build from source and mess about a bit, but fear not, I followed the guide on OSNews by Kroc on our MacBook Pro and it worked quite well, yet to try it on Linux.

{lang: 'en-GB'}
Share

Sunshine of summer: Java EE6, Glassfish 3 and Netbeans 6.8 plus TeamCity 5!

December 12th, 2009 No comments

What a whopper of a weekend, Sun has ratified Java EE 6 and also released Glassfish 3 and NetBeans 6.8 to celebrate. If that wasn’t enough JetBrains has also released TeamCity 5!

You can read all about the Sun releases on InternetNews and catchup with whats new in Java EE 6 Overview from Suns site.

Next weekend its time to move Confluence & Jira (Glassfish 2) and TeamCity 5 (Tomcat) to Glassfish 3 in a opensolaris zone and see how things progress. Did I mention I love the zones in OpenSolaris?

{lang: 'en-GB'}
Share

In the Zone, Creating OpenSolaris Zones.

November 22nd, 2009 No comments

I’m really enjoying using OpenSolaris as our server / NAS at home, its a different ball game to Linux but an interesting one never the less. One of the cool features of Solaris are the Solaris¬† Zones (or Solaris Containers). Zones are an implementation of operating system-level virtualisation where the kernel isolates multiple instances of the user-space available. Something like chroot but so much more. Unlike running under a hypervisor (like VMWare or VirtualBox), Zone’s have very little (if any) overhead.

As I’ve come to realise, because of the way Solaris works in general, you can have multiple (isolated & secure) Zones for each application service exposed by the server – eg. one for Tomcat, one for Glassfish, maybe both Apache 1.3.x and 2.x, MySql, Postgres etc. Whats more, you can limit how much resources these Zones can utilise. They all have their own configuration including network routing (coupled with OpenSolaris Crossbow) and you can make for one kick ass setup that won’t break another area of the operating system.

In the Zones.

Here’s a guide on setting up a new Zone in OpenSolaris, configuring it and booting it.

Me Against the Music, its all in the global zone

When we first install OpenSolaris we’ve already got ourselves into a zone (the parent to all other zones) which is known as the global Zone.

You can find this by trying out the following to list all the available zones on a virgin install of OpenSolaris.

opensolaris# zoneadm list -vc
 ID NAME             STATUS     PATH                           BRAND    IP
 0 global           running    /                              native   shared

The output will be something like above. Now we can go about creating ourselves a zone for playing around in.

When working with zones, we only need to worry about three commands (damn I love that!). The zoneadm command to manage the physical zone, zonecfg command for configuring the zone and zlogin to login to the zone from the global zone.

First we have to do a bit of planning and thinking about what we’re going to do about this zone.

Here are few things to consider:

  • What do you want to run in the zone?
  • Will it need networking and have it exposed outside of the machine?
  • Where will the zone reside on your disk?
  • Would you like to limit the amount of CPUs the zone can see?
  • Would you like to limit the amount of RAM the zone can utilise?
  • Do you want to automatically boot the Zone when OpenSolaris starts?

For this post, we’re going to create a simple Zone (we won’t install anything).

Toxic Zone

Creating a zone we specify a zone to the zonecfg command.

opensolaris# zonecfg -z toxic

You’ll get something like this appearing because teh zone doesn’t exist, thats fine.

toxic: No such zone configured
Use 'create' to begin configuring a new zone.

Then you will be inside the zonecfg configuration.

Lets configure this zone to have the following:

  • Reside in /base/zones/
  • Autoboot with OpenSolaris
  • Shared IP of 192.168.0.24 bound to physical interface e1000g1

Follow me:

zonecfg:toxic> create
zonecfg:toxic> set zonepath=/base/zones/
zonecfg:toxic> set autoboot=true
zonecfg:toxic> add net
zonecfg:toxic:net> set address=192.168.0.24
zonecfg:toxic:net> set physical=e1000g1
zonecfg:toxic:net> end
zonecfg:toxic> verify
zonecfg:toxic> commit
zonecfg:toxic> exit

This will create the configuration, verify, write it and exit. You can verify it was created by running the list command again:

opensolaris# zoneadm list -vc
ID NAME             STATUS         PATH
0 global           running        /
- toxic            configured     /base/zones

Its currently in a configured state, you can read more about the Non-Global State Model in the documentation. Next thing to do is to install the zone – this will get the base packages setup and configured for use.

opensolaris# zoneadm -z toxic install

Everytime, boot her up.

Next lets boot this bad baby up.

opensolaris# zoneadm -z toxic boot

Now if we do a list again we’ll see that our state has changed to running.

opensolaris# zoneadm list -vc
ID NAME             STATUS         PATH
0 global           running        /
- toxic            running        /base/zones

Now we have to configure the zone itself – just like a real machine. For this we use the zlogin command to login to the zone console.

opensolaris# zlogin toxic
[Connected to zone 'toxic' pts/5]
Last login: Sat Nov 21 17:52:43 on pts/5
Sun Microsystems Inc.   SunOS 5.11      snv_127 November 2008
root@toxic#

After that we’re now in the toxic zone. Anything we do inside here, stays within this zone and won’t affect our global or other zones. But before we continue we really should configure our networking.

First lets modify our /etc/nsswitch.conf file with vi.

...
passwd:     files
group:      files
hosts:      files dns
ipnodes:    files
networks:   file
...

Make sure the hosts entry has dns as above. Next we need to configure the nameservers.

toxic# echo 'nameserver 192.168.0.254' > /etc/resolv.conf

That will create a resolv.conf file with the nameserver which you can get from the global zone as it would be different for everyone:

opensolaris# cat /etc/resolv.conf
nameserver 192.168.0.254

Breath on me, reboot the zone.

Now we can access the networking like the global zone. So you can do a package refresh and update-image too.

toxic# pkg refresh && pkg image-update

If it succeeds we have correctly setup our zone and its ready for use – you may want to reboot the zone however. To do this, exit the toxic console.

toxic# exit
logout

[Connection to zone 'toxic' pts/5 closed]
opensolaris#

Then lets reboot the zone.

opensolaris# zoneadm -z toxic reboot
opensolaris# zlogin toxic
[Connected to zone 'toxic' pts/5]
Last login: Sat Nov 21 17:58:44 on pts/5
Sun Microsystems Inc.   SunOS 5.11      snv_127 November 2008
root@toxic#

Outrageous, removing the zones.

Now how about removing this zone and trying again? First get out of the zone console and back to your global zone. Issue the halt command to shutdown the zone.

root@toxic# exit
opensolaris# zoneadm -z toxic halt

Once stopped simply remove it.

opensolaris# zoneadm -z toxic uninstall
opensolaris# zonecfg -z toxic delete

You can make sure its gone by using the list command. That’s all there is to it!

Now you can consider yourself, In The Zone.

{lang: 'en-GB'}
Share

Java news: $10 Confluence, Jira & Atlassian products, and InteliJ goes opensource!

October 24th, 2009 No comments

In all the commotion I forgot to post about some cool developments in the Java world.

First is that Altassian are (almost) giving away copies of JIRA and their enterprise wiki Confluence for $10 for a pack of 10 users, whats more, they’re donating the funds to Room to Read. Its perfect for small teams, check it out!

If that wasn’t enough Jetbrains, the company behind InteliJ IDEA – one of if (if not the) coolest IDEs around is going to become open source¬† from v9.0! I haven’t used IDEA since 6.0 till just recently and I have to admit the time you save – after figuring out how it works, you’ll be wondering how you’d done java development otherwise. The integration of Hibernate, SQL code in string literals, Spring, RegEx, Xml are just a few of the intelisense items it will figure out.

There are a few caveats, they’re not opensourcing the whole shebang but a subset. If you’re yet to try the IDE download a copy and see.

{lang: 'en-GB'}
Share

Setting up OpenSolaris Extras Repository for VirtualBox, True-Type Fonts, Flash & JavaFX SDK

October 16th, 2009 3 comments

I’ve been messing about with OpenSolaris (you’ll know why soon!) and decided to install the OpenSolaris Extras repository so I can grab the latest VirtualBox install from the repository. This repository has the following packages (as of writing) and is recommended if you plan on using VirtualBox:

NAME (PUBLISHER)                              VERSION         STATE      UFIX
SUNWadmj (extra)                              0.5.11-0.111    known      ----
SUNWjsnmp (extra)                             0.5.11-0.111    known      ----
SUNWwbapi (extra)                             0.5.11-0.111    known      ----
SUNWwbcou (extra)                             0.5.11-0.111    known      ----
SUNWwbdev (extra)                             0.5.11-0.111    known      ----
develop/java/javafx-sdk (extra)               1.2.0.233-0.111 known      ----
service/compute/sungridengine (extra)         6.2.2-0.111     known      ----
service/compute/sungridengine/arco (extra)    6.2.2-0.111     known      ----
service/compute/sungridengine/domainmanager (extra) 6.2.2-0.111     known      ----
system/font/truetype/ttf-fonts-core (extra)   1.0-0.111       known      ----
system/iiim/ja/atok (extra)                   17-0.111        known      ----
system/iiim/ja/wnn8 (extra)                   8-0.111         known      ----
virtualbox (extra)                            3.0.8-0.101     known      ----
virtualbox/kernel (extra)                     3.0.8-0.101     known      ----
web/firefox/plugin/flash (extra)              10.0.32.18-0.111 known      ----

So what do you need to get these freebies? (source help)

  • Register if you haven’t already with Sun, otherwise login to your Sun Online Account get your certificates.
  • Download the Key and Certificate files onto your desktop. They are named OpenSolaris_extras.key.pem and OpenSolaris_extras.certificate.pem respectively.
  • Now we need to create a directory in¬†/var/pkg to store the certificates – ensuring they have the correct permissions. Then we’ll add them to the folder.
    $ pfexec mkdir -m 0755 -p /var/pkg/ssl
    $ pfexec cp -i ~/Desktop/OpenSolaris_extras.key.pem /var/pkg/ssl
    $ pfexec cp -i ~/Desktop/OpenSolaris_extras.certificate.pem /var/pkg/ssl
  • Then we add them to our configuration.
    $ pfexec pkg set-authority \
        -k /var/pkg/ssl/OpenSolaris_extras.key.pem \
        -c /var/pkg/ssl/OpenSolaris_extras.certificate.pem \
        -O https://pkg.sun.com/opensolaris/extra extra
  • To test the above worked get a list of the packages in the repository with the command below. Your output should be similar to mine above.
    $ pkg list -a 'pkg://extra/*'

Now make sure your datetime settings are valid when you do the above, as I found mine was a little out of date and raised a few python exceptions.

{lang: 'en-GB'}
Share

Learning Scala from a Java perspective

October 1st, 2009 No comments

I’ve been reading up and keeping abreast of both the .NET world and Java world this year, both have some mighty exciting advancements coming – teaser: its all about the Pentiums! I’ll try and cover some of my research into parallel work later.

One of the other areas I’ve been keen on (after hearing from the leader of our pack, Mr Wolfe) was Scala and came across a incredibly useful resource by Daniel Spiewak on looking at Scala from a Java developers perspective.

The linked article is a ’roundup’ of the many posts he’s done on the topic and covers the many facets of Scala and gives it in a Java developers perspective. Highly recommended reading if your just starting out in understanding Scala and functional programming general. I have to admit, Scala is growing on me.

F# is the key functional programming language in .NET and whilst I’ve seen them being compared quite frequently, I feel they target to different areas. From a n00bish-functional-programming perspective, it feels like Scala is all about the OO and F# is more about writing in a functional perspective. But here’s an article from 2007 that may give you a better idea or Brandon Werner‘s article comparing the functional languages.

By the same token, there’s a great introduction to F# that will cover the historical and core language.

I remember messing about 10 years ago with Delphi, VB, Java, C/C++ and thinking this is RAD, but the world seems to be morphing into the functional programming paradigm now.  What better time to start musing with it?

{lang: 'en-GB'}
Share