Tuesday, October 20, 2009

Blogger : Syntax highlighting for code

I hate the way Blogger displays code , XML etc, inside the "blockqoute" construct.

Then I came across this:

How to add syntax highlight to Blogger.

This uses Syntax Highlighter.

Just to add:

You don't need to host the files. You can use:


e.g. the link in the article would become:

Update: As per the comment:

More info. available here:

Warning: There are a number of posts around on how to do this - all slightly different - use at your own risk.


Log4J : Path to properties file

For Glassfish, we normally put the log4j.properties in the "domain / config" directory.

To enable Glassfish to find it, add the following to the Glassfish JVM settings. Easiest way is to use the Admin console i.e. Application Server / JVM Settings / JVM Options.

Add this line:



Netbeans : Generating getters and setters for a Java class

Using Netbeans 6.5.

Unlike Eclipse (where the link to do this is obvious), in Netbeans you will find this under:

Refactor / Encapsulate Fields


Metro : JAX WS catalogue

One of the problems with using Netbeans to generate web services using Glassfish / Metro is that when you want to create a new Web service client, you are asked to select the web service which is normally on your local machine.

This means that the web service has an address like http://localhost:8080 and it then becomes a problem when you deploy to other environments.

One way around this is to use a catalog to resolve the addresses at run time. The file is called jax-ws-catalog.xml and it's placed in the META-INF directory.

It looks like e.g.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
rewritePrefix="http://some url:some port/"/>
rewritePrefix="http://some url:some port/" />

This searches for any URL that starts with "http://localhost:8080/" and replaces this with "http://some url:some port/" e.g.



http://some url:some port/webserver/WebService

The ant build files in Netbeans use the -catalog option to point to a file called catalog.xml in the project root directory. You can apply the same principles to this file to resolve addresses at compile time.

Some useful links:

Using a JAX-WS Catalog

How to write an XML catalog file

Global URI re-writing with jax-ws-catalog