ArrayList in J2ME and generics
by Jim on Apr.01, 2010, under Java, j2me
As you may, or may not know, J2ME does not support the ArrayList functionality of standard Java. In addition, as J2ME is based on Java 1.3 it does not feature generics. This means as a developer you are stuck with a choice of using arrays or vectors. Now arrays are fast, but you are stuck with the initial size and a number of other issues. These are things you really do not want to be messing around with, unless speed is of the highest priority.
Whilst Vectors are dynamic, they bring about one annoying issue – you have to cast each entry back from an Object type to its original type on retrieval. This takes up a lot of processor cycles, and on phones processor cycles are a limited commodity. Secondly, you will have to use the Vector enumerator to iterate through your vectors. This is very processor intensive, in NaStar I found this was using around 30% of my cycles! Finally Vectors are synchronised, this means they are thread safe. Now a synchronised collection is much slower than an unsynchonised one; plus, you will most likely not need the safety benefits synchronisation brings. As you will usually be using one thread for acessing your collections in a game (in the main game loop.)
Now the J2ME Polish project gives you the chance to use some Java 1.5 features, most importantly generics are included. Second, an arraylist implementation is included, which uses generics. However, many people have had issues with integrating this plugin to their chosen IDE. I have worked out some fixes for Netbeans J2ME Polish integration, but when coding my project decided against using the tools.
So you now find yourself stuck between no generics, slow vectors, or fixing (and maintaining) a plugin.
If all you want is access to ArrayLists or generics, your best bet is to strip the ArrayList code from J2ME Polish and create your own lists. I guess you could simply find an implementation of ArrayList floating around on the web, but the J2ME Polish code is very good. You will then simply create a number of new ArrayList classes, such as SpriteList, EnemyList, et al. There will be two other classes that the ArrayList depends on, you should also clone these for each implementation; these will let you use for each loops! Let each list only deal with one defined type. Now you will no longer have to deal with Vectors and their iterators and will find your game runs a lot faster! I found around 20 – 60% of processor time was dealing with Iterators; whilst ArrayLists cut this down to under 10%. For my project this was the best performance tweak available.
Before anyone asks, no you can’t play my game! Sadly the rights are held by the University of Birmingham
Whilst I doubt they care much about a J2Me game!
I hate Solaris, or should that be Oracle?
by Jim on Mar.01, 2010, under Operating Systems, Rants, linux
Actually make that I hate both Solaris 9 and Oracle 9. If you ever get asked to set these buggers up on a machine just say no. It probably is a whole lot easier using the current versions! (Or get Oracle to do it for you!)
I had to get this working environment up on an old system at work (programmers get to do hardware, yay!) Running on some old SPARC boxes with not-so-healthy drives and broken backups. Sat back and watched Solaris 9 take about half a day to install! Then the nightmare began…
Next you run into issues with your standard Solaris SPARC machine being headless and Oracle deciding to require a GUI and X windows when all you would do is click ‘ok’ four or five times. So off you go setting up the server to allow remote X connections, only Solaris is bolted down in a number of places to stop this happening (think security.) SSH -x may do some things but not all you need on Solaris!
In case your getting the handy “timeout locking .Xauthority” message, as root you need to copy the /.Xauthority file into the users home directory. Then give ownership using chown to the user. You may need to set up the user’s home directory, have a look at the contents of /etc/passwd to see where the user’s home directory is located. This should reside in /export/home/username/
Then when you actually get xclock and friends running you hit another wall. Oracle needs to link a bunch of files, but Solaris 9 does not come with the required tools! Being an old system you do not get a nice apitude style installer for simple dependencies; you have to go dig around for them yourselves. In case you’re wondering where to go, they’ve been hidden on the second of three install CDs.. Then Oracle will probably crash out for another reason and you’ll be left wanting to grab the nearest gun/axe/chainsaw and finish off the decrepid system yourself.
Meamo becomes Meego, but what of the N900?
by Jim on Feb.24, 2010, under Maemo, Operating Systems, android, linux
For sometime N900 users have been wondering whether we would get Maemo 6 (Harmatten.) Whilst everyone wants the latest update on their device, and feels let down when it doesn’t happen; Nokia’s transparency with regards to bug fixes exacerbated the desire for the update. Nokia have labeled many bugs with a ‘To be fixed in Harmatten’, basically saying “live with it” — unless the N900 can be upgraded. So if Nokia do leave the N90 behind it could be a damning blow to many fans.
Earlier this month at MWC Nokia and Intel announced the merger between their two opensource Linux based operating systems. I can only assume this is an attempt to cement the operating system alongside iPhone OS and Android as one of the mainstream smartphone operating systems of the future. Whilst Nokia’s Symbian is still the top selling mobile phone operating system, its days look to be numbered with Apple and Google making a big impact in the market.
Still, I am not sure what position there is in the market for Meego. It is highly likely that we will eventually see just a handfull of sucessful operating systems for smartphones. For example, manufacturers like LG, have noticed that using their own custom systems was detrimental to their phone’s sales. Sure the hardware was good, but what use is it if no-one is making software for it? So Meego will have to fight with Android, Windows Mobile, Symbian, and eventually Bada for these manufacturers support.
The issue here is Android already has a number of devices from different manufacturers in the market and it looks like support for Android will steadily grow after a difficult first year (when only HTC offered devices.) It would be a difficult choice manufacturers to switch allegiance, but I would expect a few devices to appear (to test the waters so to speak.) Whilst Windows Mobile seems to have a strong grasp of the business market (alongside the Blackberrys.)
It’s such a shame that Nokia have decided to drop Debian as the upstream for their system with this merge. Whilst I’d like to see an updated system, I can’t say I am happy at losing the ability to install Debian packages without any worries.
So I struggle to see where the system will fit in the market; unless Nokia and Intel go for tablets…
Annoying Turkish Script Kiddies
by Jim on Feb.23, 2010, under Site Related
It looks like – for the second time – a random Turkish ‘hacker’ has decided to take down my old site. Tech Rant is a dead site running a dead Content Management Service (CMS,) hence it is going to be an easy target! I can never recall why I chose Postnuke… There’s probably a number of weaknesses in the CMS in it’s current state and with no updates available since the developers decided to drop version 8 and start with a clean slate; the site is effectively a dead duck. Let that be a lesson for anyone deciding to not choose the popular option! Be sensible and get a well supported, popular CMS like Wordpress — or do a Katy and make your own (again!)
This little escapade has reminded me that since I have already ported over all the posts from Tech Rant to here; there is little point in the site being alive. After all it will simply be waiting for the next script kiddie to come along… Once I get round to setting up a downloads database here, then the domain will simply point here for a year or so before getting dropped. I have moved the files over for now, its just setting up all the files will be a boring and loooooong task.
I have set up a few posts regarding the N900 and some nice software, so there should be some content here! At the same time I have gone through the usual duties of updating Wordpress through a good few thousand builds (it updates soo fast!) alongside a bunch of plugins.
PR1.1.1 N900 Update still not out in the UK
by Jim on Feb.20, 2010, under Maemo, Operating Systems
The N900 received an update from v2.2009.51.1 to V3.2010.02-08 on the 16th of this month; however, thi update is still not available to owners in the UK. The firmware update is not available via the N900’s application manager nor via Nokia Software Updater.
The N900 software page on Maemo.org only shows PR1.1.1 for the US, the middle east, and ‘global’. The site only offers PR1.1 for UK devices.
Previously, Nokia could hide behind the network operators who like to fill devices with bloatware; which meant the firmware needed extra testing. Often it was down to the operator to release the update, so Nokia were not to blame. However, the N900 was sold without network branding and typically direct from Nokia. So why has this update taken so long to reach the UK? And why is their a Vodaphone only variant for some users?
Nmap now on the N900!
by Jim on Feb.15, 2010, under Maemo, Operating Systems, Security
It looks like the N900 may become a network security/hackers dream phone! First aircrack, now Nmap; hopefully, we can get kismet, metasploit, air-pwn, and friends up and running on the device in the near future.
Installing Nmap is a breeze, the program is located in the extras-testing repository. I believe it is under ‘network’ in the application manager, but it’s faster to simply search for the program. To run this program, you will have to use the X terminal and simply type nmap – the application will then report a LOT of options! It’s best not to try and crash out of a scan on the N900 using CTRL+C as the x terminal will no longer accept any keyboard commands until you close it. I guess that is one reason why Nmap is still in extras-testing!
Here is the result of a basic scan, you don’t need to be root for this one; but you do for a number of options. For a basic scan you simply need to type nmap <target ip> . In the example, I had to use option -PN to find the machine; this treats all hosts as online and doesn’t bother checking if it is alive.

Nmap is typically used to find available ports/machines and the operating system (option -O) before running other tools to attempt to exploit the open ports. It’s also a nice way to check your router is doing what it should be!
For a comphrensive list of the options and more information on how to use Nmap, please see the official manual pages.
Watch Hulu, South Park, One Piece videos using a SSH Tunnel
by Jim on Feb.09, 2010, under Guides
Sadly for those of us not in America, we cannot watch the streams provided on Hulu and these other sites. So how do we watch Hulu from the UK, Canada, or anywhere outside of the US? We have to use a SSH Tunnel and some other software to trick Hulu into thinking we are from America.. Otherwise we have to wait for the latest episodes of Family Guy or American Dad to finally get relased in our respective countries… Now you may think that it would be easy to simply set up a connection to a proxy server in the United States and trick Hulu into believeing you are in America. This is not the best solution! First, you will find free proxy servers to be slow and unreliable; plus, even if you do find a working proxy, you will not be able to watch the videos on Hulu or One Piece Official, due to the way flash works.
So you are left with two options: purchase or set up a VPN connection on your own webhost/VPS, or use putty to set up a SSH tunnel and ProxyCap to connect to server in America. Thankfully, for me anyway, my Linode is in the United States! Setting up a VPN connection is a lengthy process, you really want to avoid doing so at all costs; whilst a SSH tunnel requires very little work! For those of you without a server to connect to, finding a cheap VPN is your best option for streaming video from these sites.
What you will need to do is: set up a SSH tunnel to your US server, then instruct your web browser to connect via that tunnel. This will work like setting a proxy server, but pointing to localhost/127.0.0.1 (your own computer) Putty will then force all connections to Hulu to go through your US server, and will make it possible to watch Hulu/South Park/One Piece videos.
You should already have SSH on your webhost/server. Most shared web providers will allow SSH access with the same details you use for your FTP settings. This is because SSH is far more secure than FTP; so you should be using it already!
To set up the SSH tunnel, you will need to use a certain set of options in Putty:
Once you have it set up like in the picture, press ‘add’ and the forwarded ports should state D8080 or D<your port>. Save your connection settings for later and connect to your site. Alternatively, you may use a command line tool like this:
ssh -D 8080 -p 22 -f -N exampleuser@exampleserver.com
In either case, you may use a different port than 8080.
Next in your browser, you need to change your connection settings to connect via a SOCKS proxy based at 127.0.0.1 using port 8080. The following picture shows the correct set up on Firefox:
Now you are almost there! Check your connection works, if it doesn’t it is likely you have typed in the wrong port or have not connected to your server yet, both easy mistakes. You could use the FoxyProxy extension if you wish to set up some advanced rules (e.g. use the proxy only for Hulu.)
Now you may find you can now browse One Piece Official, which you could not before; this is because you now have an American IP. Check it out on any of the hundreds of ‘what is my ip’ clones. Yet, don’t bother trying the watch any of the videos on Hulu yet, there is still one step to go! This is because Flash does not respect your browser’s settings and just does what it wants, so tries to connect via your standard connection — effectively bypassing your proxy. You will need to get a copy of ProxyCap, they provide a free 30 day trial on their site. I am not sure if the trial is like WinRar’s infamous 30 days, or if you can simply redownload it. There is a FoxyProxy video helper, which supposedly does the same job; but I can not get it to work for me. If anyone has any tips, that would be a great free alternative.
Once ProxyCap is installed you need to edit the preferences to use your proxy, click the dotted square nto the right of the text ‘Manage your proxies’. Enter 127.0.0.1 and your port, as shown below:
Next you need to update the rules to allow ProxyCap to deal with UDP, as follows:
Now go check out Hulu and enjoy some TV!
For those of you who wish to use the BBC iPlayer this will work in the same manner, just get a UK based server
Freeme2: an alternative to Fairuse4wm
by Jim on Feb.07, 2010, under DRM, Security
This handy program – Freeme2 – is an open source project that removes pesky Digital Rights Management (DRM) protection from Windows Media WMA audio files and WMV video files. This is rather handy for those older MP3 downloads you may have purchased, as many sites are now selling their music without DRM. This program is a little harder to use than FairUse4WM, but it’s always nice to have an alternative in case FairUse4WM does not work; however, you may prefer Freeme to FairUse4WM!
There are download links both in the middle and one at the bottom of this article.
This post is taken from my old site Tech Rant. For some reason the exported xml did not contain this post, so for that reason I am recreating the post. I know that Tech Rant got a lot of traffic for providing links to software such as FairUse4WM; so I feel this site should begin to take some of the burden away from the old one.
When using FreeMe2 you have the choice of using the third party helper program or manually using the command line to free individual tracks of DRM. Download links and instructions on how to use both versions of the software are included in this post. For those who are not command line savvy, or are used to FairUse4WM’s interfact, I highly recommend you use a GUI when using FreeMe.
FreeMe2 should also work with Vista and should also run on Windows 7; although, problems have been reported with Vista. If you are using Windows 7, you should try using XP Mode; the tool should be more reliable. Alternatively, you can always try running FreeMe in a virtual machine; such as VirtualBox.
Please only use these program to remove DRM from files you already own, or for educational purposes. 406NotAcceptable and Tech Rant do not condone piracy.
Please remember that none of these download links are hosted by any Linode, 406NotAcceptable, Dreamhost, or Tech Rant server . They are all external. Always use a virus scanner when downloading files from third party sites.
Download links
Latest Version, source, and help file
Latest version
FreeMe2 Helper
Instructions for use with FreeMe2 Helper
Simply copy the executable into the same folder as freeme2.exe. You can to drag and drop complete folders on it which are being processed recursively (i.e. with all subdirectories).
Instructions for use without helper:
From the readme
How to use freeme2
Freeme2 is a command line application. You need to learn how to use Windows command console to run it.
How to use freeme2 to remove DRM from Windows Media .WMA and .WMV files (command line console)
1. Put your DRM protected media files in the same folder as Freeme2.
2. Run the Windows command console: Hit “Start”->Hit “Run…”->type CMD->Hit the “OK” button.
3. Then, once in the command console, change the directory by using the “cd” command to the directory where your FreeMe2 is located.
4. Extract your license keys. You can do this with drmdbg.
5. Type the following in the command line console:
Code:
freeme2 <name_of_drm_wma_file>
and press the Enter button
How to use freeme2 to remove DRM from Windows Media .WMA and .WMV files (drag-n-drop)
Drag-n-drop method is much easier than the one using command line console:
1. Put your DRM protected media files in the same folder as Freeme2.
2. Extract your license keys. You can do this with drmdbg. If you use drmdbg you can
take the drm2-i.key file generated by drmdbg, rename it to drm2.key and copy it to the FreeMe2 folder.
3. Drag your sample.wma file onto FreeMe2.exe. It starts up and runs fine.
The latest version of FreeMe2 supports decryption engine from MPlayer. There are three options to use freeme2: v,s and 2. Any combination of those is valid:
* v – verbose mode
* s – ask for SID
* 2 – use FreeMe2 original decryption engine (by default we use MPlayers one).
Example configurations:
* Decrypt file
Code:
FreeMe2 some_file
* Decrypt file in verbose mode
Code:
FreeMe2 -v some_file
* Decrypt file but force program to ask for sid
Code:
FreeMe2 -s some_file
* Decrypt file but force program to ask for sid in verbose mode
Code:
FreeMe2 -vs some_file
* Decrypt file but force program to ask for sid in verbose mode using FreeMe2 decryption engine
Code:
FreeMe2 -vs2 some_file
Download link
Freeme2 is a freeware open source piece of software that removes Digital Rights Management (DRM) protection from Windows Media WMA audio files and WMV video files. This program is a little harder to use than FairUse4WM, but it’s always nice to have an alternative in case FairUse4WM does not work.
<a href=”http://rapidshare.com/files/132357269/freemecollection.zip>Latest version, source, and help file
When using FreeMe2 you have the choice of using the third party helper program or manually using the command line to free individual tracks of DRM. Download links and instructions on how to use both versions of the software are included in this post.
FreeMe2 should also work with Vista; although, problems have been reported.
Again only use these program to remove DRM from files you already own, or for educational purposes. Tech Rant does not condone piracy.
Please remember that none of these download links are hosted by Tech Rant or Dreamhost servers. They are all external. Always use a virus scanner when downloading files from third party sites.
Download link
<a href=”http://rapidshare.com/files/132357269/freemecollection.zip>Latest version, source, and help file
Instructions for use with FreeMe2 Helper
Simply copy the executable into the same folder as freeme2.exe. You can to drag and drop complete folders on it which are being processed recursively (i.e. with all subdirectories).
Instructions for use without helper:
From the readme
How to use freeme2
Freeme2 is a command line application. You need to learn how to use Windows command console to run it.
How to use freeme2 to remove DRM from Windows Media .WMA and .WMV files (command line console)
1. Put your DRM protected media files in the same folder as Freeme2.
2. Run the Windows command console: Hit “Start”->Hit “Run…”->type CMD->Hit the “OK” button.
3. Then, once in the command console, change the directory by using the “cd” command to the directory where your FreeMe2 is located.
4. Extract your license keys. You can do this with drmdbg.
5. Type the following in the command line console:
Code:
freeme2 <name_of_drm_wma_file>
and press the Enter button
How to use freeme2 to remove DRM from Windows Media .WMA and .WMV files (drag-n-drop)
Drag-n-drop method is much easier than the one using command line console:
1. Put your DRM protected media files in the same folder as Freeme2.
2. Extract your license keys. You can do this with drmdbg. If you use drmdbg you can
take the drm2-i.key file generated by drmdbg, rename it to drm2.key and copy it to the FreeMe2 folder.
3. Drag your sample.wma file onto FreeMe2.exe. It starts up and runs fine.
The latest version of FreeMe2 supports decryption engine from MPlayer. There are three options to use freeme2: v,s and 2. Any combination of those is valid:
* v – verbose mode
* s – ask for SID
* 2 – use FreeMe2 original decryption engine (by default we use MPlayers one).
Example configurations:
* Decrypt file
Code:
FreeMe2 some_file
* Decrypt file in verbose mode
Code:
FreeMe2 -v some_file
* Decrypt file but force program to ask for sid
Code:
FreeMe2 -s some_file
* Decrypt file but force program to ask for sid in verbose mode
Code:
FreeMe2 -vs some_file
* Decrypt file but force program to ask for sid in verbose mode using FreeMe2 decryption engine
Code:
FreeMe2 -vs2 some_file
Download link
Latest versionDownload link
Update on Aircrack for N900
by Jim on Feb.03, 2010, under The real world
It seems there are a number of issues with Aircrack on the N900. Whilst you can sniff packets and sometimes injection may be successful; many other features do not work.
This looked to be an early success for the the N900. Sadly, aircrack is not that useful at the moment. As it sees every network as being on channel 6. Airodump-ng does not work on the latest SVN version; unless you are actually connected to the network (which renders it pointless.)
Before I go testing other utilities on the N900 I really need to flash my device. For no apparent reason I did not get the PR1.01 update pushed to my device; so I have had to make do with a manual update using apt. This has left my N900 in a weird state. All my applications are working with PR1.1 features (e.g. rotation, Ovi store) but my device reports as using PR1.0




