Tuesday, October 7, 2008

Classpath Doh!

I keep learning more and more about building complex systems and the importance of getting classpath correct.

The other day I did an SVN update on my project. All of the sudden, this one piece of code wouldn't compile. I think it's probably OK to show this 1 line of code.



Anyway, the bit that was barking at me was javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI.
I asked a colleague where this lives. In rt.jar, he says. Waa? OK. It's in the JDK. I looked around in rt.jar. Yep. It's there. Why the hell isn't it compiling then?

Hmm. Here's the answer.

Project | Properties | Java Build Path | Order and Export
There was a jar in our project (which wasn't being used any longer) called jsr173_1.0_api.jar. That jar contains a class in the javax.xml package called XMLConstants just like in RT.jar. Only this copy did not have javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI. But, why does that affect whether it compiles or not? The jar without the class was listed higher in the classpath order. We didn't notice the problem before the JDK was previoulsy higher in the classpath order. Someone had re-ordered it on the last commit. Ugh. But, I'm glad they did it.

It was an easy fix for us. We were able to simply remove the unused jar from our project and the problem was gone. But, what if we couldn't remove it? Hmm. You can cheat, at least in the IDE. Though I'm sure that might have caused deployment issues. You can re-order the classpath by moving a class up or down in the list. Just click the jar in question and move it below the JDK entry. Voila, it compiles.

Be careful out there. It's a weird classpath world.

Friday, October 3, 2008

Android and sqlite3

Wow. For my new application which will go unnamed at the moment, I learned something very cool.

In the Eclipse Android SDK for Eclipse, there is a Perspective called DDMS. While your emulator (and application) is running, this will let you do all sorts of cool things. You can take a screenshot of what's showing on the phone. You can debug, look at logs, etc. It also shows you the filesystem for your application. Since your application is a its own Linux account, it has its own set of files and applications. And, if you are like mine and have persisted data using the built-in sqlite3 database, the database is also there on the filesystem. If your app is called foo.myapp then it's under /data/data/foo.myapp/databases.
There will be a file that is the name of the database along with any tables.

Let's say your database is called MyDatabase and you have a table, mytable.

Now click on the databases folder and click the action menu item for that view "Pull a file from this device". It will actually copy this whole directory to your local filesystem.

Now, hopefully at this point you are in Linux and already have sqlite3 installed. You do run Ubuntu right? :-)

Bring up a shell. Fire up sqlite3 like so:



That's it. It should list the contents of your table (assuming you have a column named col1). Other than that, it's standard sqlite3 stuff.

There should be a lot of neurons firing right now about what this means. Perhaps involving snycing. You can add files back to the device. And, this sort of thing can be done with a standalone emulator, so no eclipse is required.

Enjoy!

Tuesday, September 16, 2008

Pluck Me

Having used Ubuntu now for some time. I figured I needed a little shell scripting practice. I admit it. I'm lazy. I don't want to go through a bunch of unnecessary clicks every time I use Sunrise (my app for PluckerDocs on my Palm Treo). Alas, my Treo is dying on me. It won't be much longer I'll be using this type of offline reading, unless I port it to Android or the iPhone. In the meantime, let's do it. So, normally I would just write something in Java. It's easy enough. I know Java well and it's easily accessible from the command line. It would have been simple. But, it must have been years since I've written a Bash script. So, here goes.

All this script needs to do to replace my monotony is do this workflow:

Old way
- I open Sunrise and tell it to update everything. We wait. It's takes some 5 minutes to pluck everything.
- I put in the SD (ugh, still gotta do that manually)
- I open my Pluckerdocs folder (the source).
- I open my SD card folder (where my Palm reader will see them, the destination)
- I remove the old pdb files b/c my old 1GB SD card drive died and I'm living off a 34 MB SD Card. Life is tough.
- I empty the Trash in Gnome. Yes. Another manual step if you aren't using the command line, else the card will look full.
- I copy over the new files

New improved Bash way
- I open Sunrise and tell it to update everything. We wait. It's takes some 5 minutes to pluck everything.
- I put in the SD (ugh, still gotta do that manually)
- I run the script (this is new!)
- Done!

Next on the list might need to be something fun like running sunrise headless and kicking off an update or something. That would be pretty cool. Running it as a job.

Here's the script. Yeah, it's tiny. So what?

Sunday, July 13, 2008

Plurk

Yes, I'm out there. I just joined another one. This time it's Plurk.

This is interesting. Like Twitter (I don't see any SMS support). I also like Pownce (who also doesn't have SMS support, but lets you share files!).

The cool thing about Plurk is that it has this nifty timeline UI. Interesting.

It appears to be written in Python (or at least partly). I believe the same is true of Pownce. Python and Ruby are coming along. That's cool. The more the merrier. I love languages.

Plurk sounds kind of nasty.

Wednesday, June 18, 2008

I love me some Ruby

So, I'm learning Ruby and Rails at home, and I'm absolutely loving it.

I love the little idiomatic stuff that make typing in it so concise.

Let's say that I have a list called mylist. I want to add an object to the list, foo.

In Java, I'd have to go something like this.



In Ruby, it's just this:



It's not earth shattering, but there are a dozen examples like this that I really like. If you understand the symbols and operators of the language, it actually reads just fine. Maybe I'm getting cranky in my old age and not wanting to type out all that stuff as much anymore.

Another perhaps bigger example was the "attr_accessor" convenience method.



What just happened here? For me, the critical part was the getter/setter bits. In Java, I'd have to select a menu option in Eclipse to generate the getter's and setter's for this class. Imagine a class with 10 fields in Java. You are NOT gonna type out those methods.

In the Ruby case, it's just 1 line of code. And, you can add more fields to the same line. "attr_accessor" tells us that what are our accessor methods. Nice!

See also attr_reader and attr_writer which do as you would expect, allowing only read or only write methods.

Alfresco partnering with Adobe

I just randomly hit my bookmark for the Alfresco blog today and was like...whoa!

It appears Alfresco is partnering with Adobe now on forms. They're gonna embed the Alfresco repository as part of the LiveCycle suite. Wow. Congrats if that works out for ya. Not sure how that works yet but I'm intrigued. I was just speaking with a colleague about forms applications and how badly OpenText did it in the past. Not sure if their competitors did it any better. Having not worked with LiveCycle directly, I cannot say that this is a good thing, only it's a big thing. Something to keep an eye on.

Here's the Press Release.

Read more... on their blog.

Wednesday, June 11, 2008

MyEclipse Quirk

I discovered a really weird UI quirk with MyEclipse today. I updated a thread on the MyEclipse forum for good measure. But, this is the issue:

I've seen this where case where the Add button on the Manage Deployments dialog is grey or greyed out. It's the weirdest thing. This was happening to me on Ubuntu Linux today but I don't think that matters. Also, I'm using MyEclipse 6.x. And, this also happened to a colleague of mine using Windows a few weeks ago. It was maddening and I couldn't figure it out at the time.

It seems that if the current open project doesn't have focus, this occurs. Make sure to click somewhere on your project in your project explorer. Then click the Deploy button again to bring up the Manage Deployments dialog.

So, to re-create this problem click on a closed project on your package explorer then try to deploy. It should be greyed out.

I don't know if this is really a bug as much as it is a UI quirk?