See this post:

Java calculator

It basically is implementing the shunting-yard algorithm, but is slightly out of date. I think I have a newer version of that code somewhere on my computer, but...