Loving hsqldb

Been in the marked for an embedded Java database technology and have started playing with hsqldb. I’ve gotta say it’s a very nice little tool. Uses JDBC, writes to text files, and the SQL support is way beyond what I expected (including referential integrity!). Comes with a couple of nice little admin tools to boot!

I’ve given it a hammering with JMeter, and whilst it’s nowhere near as performant as MySQL (~200 transactions/minute vs ~12000 transactions a minute on the same hardware with a 10 user load), for embedded apps it’s just awesome. I’m wanting to use it as a scratch database for Unit testing which it will be ideal for. Great job guys!

[Read More]

Embedded db advice?

I need to track down a small database for embedded use. I’m hearing that hsql gets a fair bit of traction, and I’ve read stuff about McKoi too.

Anyone got any recommendations? The constraints are: (1) Must run in-process/embedded (2) Must support multiple tables (3) Must handle modest size dbs (eg 20 Mb) (4) If commercial, must not be royalty-based

All options welcome!

[Read More]

Ultra lightweight http server

I’m developing some software that needs an embedded http server, and I’ve been looking around for tiny options. Give that it’s all java, I’ve looked at tiny versions of tomcat, jetty, and other minimalist solutions. Most stuff weights in over a meg.

But now I’ve found something just my size: 1 file! Check out Nanohttpd. I put it into the system last night, subclassed it, and plugged in my own serve() routine in the descendant and bingo! Instant HTTP - and under a BSD license to boot.

[Read More]

Loving Remote Debugging

People have told me about Remote Debugging before, but yestday I set it up and it absolutely rocks!

On very large server-side code, it is so much cooler (and faster) to be able to set a breakpoint in the middle of a massive call stack (rather than just keep inserting logging code).

I picked up the required switches on the Tomcat site (Setting up Tomcat for Remote Debugging), and used the technique on a bunch of non-web apps. Also discovered you need to use the ant task to make all this happen from ant.

Eclipse is one rocking IDE, and it just keeps getting better. Setting up Remote Debugging is as simple as /Debug/Remote Debugging/New… Gotta love that. Give it the same port that you specified when lauching the remove JVM and you are in business.

Extremely cool!

[Read More]

Pumped about SWT..

Just curious, anyone doing any SWT these days (the native-ish widget set that comes with Eclipse)?

I’ve come to the conclusion that it’s not really the speed that bugs me about Swing, or that fact that the API is so mammoth, or the fact that GridBayLayout is ridiculously complex to deal with for someone who doesn’t do GUIs all that often (like me). To be honest, I can write that off to not being smart enough, and I can live with all that.

But I’ve tracked down what I really don’t like about it. It’s the fact that it’s just plain ugly.

I’ve been playing with Apache JMeter to do some web scalability testing on my MightyBlog app (JMeter is one flippin cool tool BTW), but the GUI is just ugly. Any it’s not the layout, which is just fine. It’s the widgets themselves! What is the go with Tree widget?

Anyways, so I’m going to have a play with SWT and see what I can come up with for the little spam filtering app I’m working on. Apparently they’ve even ported it to PocketPC, so I can deploy native-looking J2ME apps to the Ipaq. How cool would that be?

So, anyone done any SWT? I’m keen for others experiences, since the doco is pretty light on. Matt pointed me to the Online doco that comes with Eclipse, which actually looks really good, and I’ve CVS’ed the example tree from dev.eclipse.org, so that should be more than enough to get started.

Very pumped.

[Read More]

Fun with Apache JMeter

Don’t know if you’ve ever had a need to do scalability testing, but I’ve always been a bit interested, and I thought I’d track down some tools.

Anyways, last night I began playing around with Apache JMeter and it’s pretty darn cool. It’ll simulate a bunch of threads/users, and give you a cool graph to check out as well. It’s a bit of a pain to configure (but the manual is very good), and you can set it up as a proxy and just capture your script directly from your browser (which is pretty darn cool - and time saving).

One this I have noticed is that Jmeter runs slow under JDK 1.3. Every time it hits a redirect it waits for 20 seconds. Run it under 1.4, and life is great! Must have been some tweeking in URL timeouts between those versions.

Anyways, recommended.

[Read More]

Tomcat, JNDI, JSTL, and No suitable driver

Been mucking around with getting JSTL to use a JNDI data source, and Tomcat has been giving me all sorts of grief. I knew my web.xml was right… and I’d created the JNDI source using Tomcat’s own admin interface, so I figured that was ok.

But every time I gave it a whirl, I’m getting the dreaded: DataSource invalid: "No suitable driver" deal. The mysql jar file was happily in CATALINA_HOME/common/lib, so it wasn’t that.

Turns out you need to have commons-dbcp.jar and commons-pool.jar in your /common/lib directory as well. I wasn’t specifying dbcp as my connection factory, so I don’t know what gives with the dependency there. But, whatever. It’s fixed now.

Anyways, that’s the story. I’m documenting this so that when I forget what the fix is I can hopefully find it via Google. ;-)

[Read More]

First Experiences with JNI

Never done any JNI before, but recently had a need, and it turns out that it’s a whole lot more straightforward than I was anticipating. In my case, I needed to make some mods to an existing Win32 DLL, so YMMV.

In a nutshell, the process goes like this:

* Define the methods you need as **public native** in your Java class. These guys are just stubs to the C calls you'll be making down the track, do don't put in any method body (just like an interface!)* Define a static initializer for your class which contains a call to your relevant library: `System.loadLibrary("myWinDll"); // but without the .DLL bit `
<li>Compile up your class so you get yourself a class file.
  • Run javah over your compiled class. Which is going to give you a header file
  • Implement the header file methods in your C source.
  • Compile it up!
  • Make sure the DLL your access is in your path… then start up your Java app!

I was doing all this in VC 6.0, and found that when I used a Debug build I generated GPFs., the release builds worked fine.

If you’re looking for a very cool JNI how-to (which is Unix-centric, but the same principles apply), check out ringlord.com.

[Read More]

POPing with JavaMail

I’ve been toying with building a simple Java spam filter for a while, and last night I actually got things off the ground. First things first, I need to get the stuff off the server, so I had a scout for some POP3 libs. Turns out there’s a few out there, but I figure that JavaMail from Sun has got to be worth a look (and I’ve got Elliotte Rusty Harold’s excellent “Java Network Programming” sitting around with a whole chapter on it).

One of the advantages of going with JavaMail is that the transport is pluggable. I can change between the Pop3 store and the Imap store relatively painlessly. The other advantage is that you get serious message parsing for free. Rather than have to do your own parsing of the message contents using RegExp or whatever, Sun have implemented the RFC for you, so you get to recipients as an Address[]. Loving their work. Need to get to the source contents of the message? Message.writeTo(OutputStream) .. in my case a ByteArrayOutputStream… but whatever. It’s there and it’s good.

The javadoc says that the Message objects I’m getting back are “lightweight” - meaning their contents only gets filled when you make a call against a getter. Not sure if it really works like that (maybe for Imap, unlikely for Pop3). Must give it a try.

Anyways, my messages are now downloading. Next step is to get them into a db or filesystem so I can keep them around till in case the engine I develop is too aggressive. ;-)

[Read More]

PocketPC one month on...

About a month ago, after years of faithful service, my Psion Revo Plus died. After looking for a suitable replacement, I ended up with a HP Ipaq 1940. Very cool little pda - ultralight/thin with bluetooth built in, and came with 128 Mb SD thrown in.

Well, I never thought I would be able to live without an actual keyboard, but it definitely can be done. At first I used the on-screen keyboard, which was kinda cool with autocompletion, but still too slow when compared with the real thing. Then I got hooked on transcriber - and I’m loving ever second of it.

I gave up on Pocket Outlook on the first day since it couldn’t give me the week at a glance view I was so used to with the Psion. Entering start and end times was so painful I just gave up. No support for a tree view of tasks. The list goes on. Ended up replacing it with Pocket Informant (which is one amazing PIM). I gave me week-at-a-glace, notes with preview, categorised tasks with priorities, it’s just amazing. And ALL the interfaces are useful. Meeting entry is a dream - those guys have really done their homework. Absolutely essential.

The next essential app, was a decent Battery Monitor. The built in one just tells you %, and becomes a pain when you get to < 25%. Enter Battery Pack Pro from Omega One. Gives you minutes remaining in your task bar, adds some very snazzy diagnostics to your Today page, and let’s you set up an App bar on your today page for launching your fave apps without having to pull down menus. Also gives you an on-screen power-off button to save wear on your device. Great app. I charge me device much less frequently cause I actually know how much life is left in the battery based on my usage pattern.

Now I just need to find a password storage app with crypto that I can use for my banking stuff, and life is great.

[Read More]

jFreeChart

Have been wanting to investigate a decent charting component (for both Web and Swing use) for a while, but haven’t had the time. Did a bit of surfing, and I’ve just come across jFreeChart (http://www.jfree.org/jfreechart/) which looks just sensational.

Tried out the demo app that ships with the product and it does a truly amazing number of charts, in a very tight amount of code. The dynamic charting stuff looks truly funky. Can’t wait to take it for a test drive.

[Read More]

DataStudio (useful query tool)

I’ve been using AquaFold’s cool little Java-based query tool - DataStudio (http://www.aquafold.com). Very neat. What I like about it:

* SQL Command Completion (including your own table/field names) * Editable result sets * 100% Java - so use it on your platform of choice * Free for personal/educational use

Worth a look. Just drop in your own JDBC driver and you’re good to go. I’ve tested against mySQL and Sybase and it works a treat.

[Read More]

dnsjava - a DNS Library

If the limitations of InetAddress get you down, you can go the whole hog and interrogate your DNS Zone! Ever wanted to find out the MX record for a given domain programmatically? Now you can!

Came across this groovy little “dnsjava” library while looking into java mail servers. Download the source from http://www.dnsjava.org/

Even comes with a port of dig written in Java… This guy is very sharp!

[Read More]

SNMP Libs

Have had to add some SNMP capabilities to an app recently (basically the ability to generate traps when bad things happen), so I’ve done a bit of scouring for available libs on the net. I originally looked at SNMP adaptors for JMX, but haven’t found any open source ones out there. (Anyone?)

Of the three or four SNMP libs that I looked at, I settled on Jon Sevy’s package at: http://edge.mcs.drexel.edu/GICL/people/sevy/snmp/snmp.html

What I like about it is that it’s simple to use. Which is what you want in an SNMP package. Also comes with some nice little demo apps that generate and catch traps, and interrogate SNMP services on remote hosts. Very cool stuff. Recommended.

[Read More]

Catching Signals

Ever wanted to catch O/S Interrupts in your Java code? Things like CTRL-C on Windows or various SIGs on your fave brand of Unix. Well it turns out you can!

A friend from work tipped me off to a feature introduced in JDK 1.3 where you can call Runtime.addShutdownHook(Thread yourHook). You pass in the thread unstarted, and when the VM gets a shutdown signal, it’ll start your thread.


        Runtime rt = Runtime.getRuntime();

        rt.addShutdownHook(new Thread() {

            public void run() {

                System.out.println("Ah-ha! You killed it!");

                System.out.flush();

            }

        });

Neat, huh! For more info check out http://java.sun.com/j2se/1.3/docs/guide/lang/enhancements.html#hooks

[Read More]

Same Guy, New Weblog

It’s been way too long since I’ve blogged regularly. But I’ve now got MT up and running, life is good again. Now I just need to track down some cool MT templates. Watch this space.

[Read More]