Category Archives: Java

Organising Eclipse static imports

By default Eclipse “Organise imports” doesn’t deal with static imports, so if you are using JUnit and want to write something like assertEquals(), it won’t be imported. However, you can add static imports to your Java preferences to get them … Continue reading

Posted in Eclipse, Java | Tagged , | Leave a comment

Closures in Java?

There has been discussion about including closures in Java for a few years now. They are already in languages like Groovy, Ruby and Scala, so the lack of Java closures makes Java look a bit tired. However, I didn’t realize … Continue reading

Posted in Java | Tagged | Leave a comment

Gradle – Groovy based build system

An interesting new build system, based on Groovy: http://www.gradle.org/overview.html  

Posted in Groovy, Java | Tagged , | Leave a comment

Http coding and testing

A few days ago I blogged about writing a dummy server to use for testing. However, rather than just writing on a socket, the code I’m writing uses http and as it happens, there are some useful libraries you can … Continue reading

Posted in Java | Tagged | Leave a comment

Socket code – answer

Did you spot the bug? The server writes to the socket using: out.write(“From server: ” + nextResponse); The client reads using: while ((fromServer = in.readLine()) != null) { However, the PrintWriter write method doesn’t put a carriage return at the … Continue reading

Posted in Java | Tagged | Leave a comment

Socket code – spot the bug

Recently I’ve been trying to test some code that interacts with a third party over http. I’d like to test as much of the code as possible, not just the code that prepares the data, but also the code that … Continue reading

Posted in Java | Tagged | Leave a comment

Printing Ant classpaths

Debugging Ant classpaths can be a bit of a pain, but the following link shows you how to print them out: http://www.javalobby.org/java/forums/t71033.html Even better, you can do a pretty version using: http://blog.andrewbeacock.com/2005/08/pretty-printing-java-classpaths-using.html

Posted in Ant, Java | Tagged , | Leave a comment