Java

AspectJ Maven Tempate

I've been pretty busy with a new job recently. I've not been able to find a complete Maven+AspectJ template on the Internet, I though I'd quickly knock one up and pop it on Github.

It contains:

  • pom.xml with necessary dependencies and plugins
  • an aspect
  • a class that aspect advises
  • a test to ensure the aspect is correctly applied

https://github.com/alexec/aspectj-example

Enjoy.

VirtualBox Java API v2 Released, v3 Roadmap

I've release v2 today. Details can be found of the issues on Github. The top issues are:

  • Support for patches
  • Better support for 64bit hosts
  • Example projects for Ant and Maven

The roadmap for v3 will focus on performance:

  • Use a single global caching and snapshotting system for much faster start-up.
  • Gradle examples.

Reverse a Java ZIP into Maven Project

1. Unzip the jars

unzip app.zip -d dist
mkdir classes
find dist -name '*.jar' -exec unzip -B {} -d classes ';'

2. Download JAD and add to you PATH.
3. Decompile classes
mkdir -p src/main/java
cd classes
find . -name '*.class' | while read F ; do D=../src/main/java/$(dirname $F); mkdir -p $D ; jad -o -s java -d $D $F ; done
cd ..

4. Get resources:

Tips for Writing Maven Plugins

I've spent a lot of time recently writing or working on plugins for Maven recently. They're simple, rewarding and fun to write. I thought I'd share a couple of tips for making life easier when writing them.

Tip 1: Separate the Task from the Mojo

Initially you'll put all the code for the mojo into the mojo's class (i.e. the class that extends AbstractMojo). Instead think about separating the task out and having minimal shim code for the mojo. This will:

JavaHelp Skeleton Maven Project

I couldn't seem to find one, and the only Maven JavaHelp plugins I could find seemed to be dead.

On GitHub.

Swing Utils

I've been doing a lot of Swing lately (don't laugh, it's still a big deal). There one or two basic things that are missing, so I've knocked together some lightweight implementations with no licensing.

5 Tips for Unit Testing Threaded Code

Here's a few tips on how take make testing your code for logical correctness (as opposed to multi-threaded correctness).

I find that there are essentially two stereotypical patterns with threaded code:

Snippet: Can't Remember That -XX Option?

A handy recent find:

% java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
...
    uintx MinPermHeapExpansion                      = 327680          {product}           
    uintx PermGenPadding                            = 3               {product}           
    uintx PermMarkSweepDeadRatio                    = 20              {product}  
...

5 Minute EasyB BDD Tutorial

This is a 5 minute tutorial on how to write a test story using EasyB, a Groovy based behaviour driven development system for Java.

You'll need Maven installed and you may want to have an IDE with Maven and Groovy integration. Additionally, both IntelliJ and Eclipse also provide EasyB plugins that allow you to run individual stories.

Firstly create a skeleton project, and add these plugins to your POM:

Snippet: JavaFX Maven POM

I could not find a good example, so here's my template.

Pages

Subscribe to RSS - Java