donderdag 1 juli 2010

Using property file outside of runnable JAR with spring

What I needed to deliver was quite simple, a runnable jar file configured by a property file located in the same directory as the jar file.

As it turns out, the classpath of runable jar files does not include the execution directory, so i needed to come up with another solution.

That solution turned out to be as simple as the problem, apart from the fact that i spent half a day to figure it out. This was the bean description in the spring context.xml :

<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:environment.properties"/>
</bean>

and this is what it should look like to get spring to load the property file from the execution path :

<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:environment.properties"/>
</bean>

donderdag 25 maart 2010

Getting started with GWT 2.0, GXT and Eclipse

GWT 2.0.3
Ext GWT SDK 2.1.1 for GWT 2.0
Eclipse Galileo

1. download latest GWT 2.0 release from http://code.google.com/intl/nl-NL/webtoolkit/download.html and unzip it

2. download latest version of GXT for GWT 2.0 from http://www.extjs.com/products/gwt/download.php and unzip it

3. install the eclipse plugin
- in eclipse select "Install new Software" from the "Help" menu
- in the "work with:" field, enter "http://dl.google.com/eclipse/plugin/3.5" (or see http://code.google.com/intl/nl-NL/eclipse/docs/download.html for other eclipse versions)
-install the plugin
-restart eclipse

4. set the SDK for the plugin
- select preferences from the Window menu
- Select Google->Web Toolkit
- click "Add..." and browse to the folder where you unpacked GWT
-click "OK"

5. create a GWT 2.0 project
- select file->new->other
- in "Google" select "Web application project"
- click "next"
- enter a name
- enter a package name
- uncheck the box "Use Google App Engine"
- click "Finish"

You now have a new google web toolkit project with an example application. Try to run the example by selecting Run As->Web Application from the Run menu.

Now we need to enable the GWT project to use GXT

in gwt.xml include this line :
<inherits name="com.extjs.gxt.ui.GXT" />



in the default html page [projectname].html add the GXT css :
<link rel="stylesheet" type="text/css" href="css/ext-all.css">


then copy the 'css' and 'images' directories from the 'gxt dirercotry'/resources to the war directory and you are all set with GWT 2.0 and GXT!



dinsdag 20 oktober 2009

QNH GameRace 2009

This year there was no RADRace, instead QNH organised the GameRace 2009.
I entered with my colleague Jamie Craane.

We chose to use Java and Groovy.

One of the challenges was to make a pong player application which could get information from the gameserver and act accordingly to bounce the ball back.

After the first day, completing some of the other challenges we had just begun on solving the pong puzzle. One tactic is just to try to get the pad to match the Y-position of the ball. But, there is another way.

During the trip back home we started to think about possible ways to predict where the ball would hit the X=0 line after it had left our pad. The first draft of the algorithm we came up with looked somewhat like this :

predictYpos = ( ( ballXpos- ( gameFieldWidth * 2 ) ) * abs(ballXtep) / abs(ballYstep) % gameFieldHeight ) + ballYPos

this was not a bad start but it only works if the ball is moving in positive x and y direction.

This is about the implementation of the algorithm we used, in the past couple of days we have updated this algorithm and written some code to make the perfect pong player!

Will post code soon...

donderdag 19 maart 2009

Error'd @ tropenmuseum



VOC ships , from left to right : "you can now" , "safely turn off your computer"

Google streetview



Its a good thing Google protects privacy by blurring out licence plates!