Archive for the ‘java’ Category

Ever wanted a Java Scratchpad or a way to run Java Snippets?

February 3rd, 2016

I quite often find myself wanting to write quick snippets of java. Similar to little bash scripts.

This usually means I have to:
- launch eclipse
- start a new project
- create a new class
- write public static void main
- try to remember why I started eclipse…..

Well no more. I decided we could do things better. I present:

JPad - It lets you run little snippets of java code and instantly see the result rendered (hopefully) beautifully as either html tables or in a console mode..

Let me know what you think? Do you find it useful? Can we make it better? Definitely!

Apologies but there’s lots of bugs and we need to improve result presentation)


Html Documentation Generator for JOpt

April 18th, 2014

JOpt Simple is a Java library for parsing command line options. If anyone else is looking for an html documentation generator for jopt here it is

We use it in sqlChart - our sql database command line chart generator.

Option (* = required) Description
-?, --help Display a help message and exit.
-D, --database <db_name> The database to use.
-H, --height <output_height> Set the height of the chart output (default: 300)
*-P, –port <port_num> The TCP/IP port number to use for the SQL Server connection.
-W, --width <output_width> Set the width of the chart output (default: 400)


Signing exe and jars in an ant build

February 19th, 2013

Easiest way to sign your java jars and exes from ant:

1. First some prep to speed things up:
- set your domains whois information to match your business
- register with a phonebook company: or
This means when they ask for it later, you already have it done.

2. Cheap keys are available at tucows author:
This article details the steps and downloading the key (use IE at all times):

3. Once you have it, use these instructions to export it as a file:

4.For signing jars:
This guide steps you through:

5. For signing .exes get JSign and add it’s ant task.

java , , , ,

Best Method of Creating Windows Installer for Java Programs.

January 23rd, 2013


  • Installer that adds link to start menu and file associations to windows
  • Running program appears as an exe and has its’ own file name in windows task manager
  • Use the built in JRE where possible or ask user to download if not available (bundling considered too large)

The finished installer can be seen at


The best solution I found was launch4j and innosetup


Launch4j was the only wrapper I found that let me keep a jar and have multiple exe’s that pointed to the same jar. Allowing me to have two programs but not double the size. One config to keep in mind when doing this is to use the chdir option with . to ensure paths work out properly.


the tricky part with inno setup was getting the file associations to work. Here’s what I used:

Name: "{group}\qStudio"; Filename: "{app}\qStudio.exe"
Name: "{group}\sqlDashboards"; Filename: "{app}\sqlDashboards.exe"
Name: qAssociation; Description: "Associate .q extension"; GroupDescription: File extensions:
Name: kAssociation; Description: "Associate .k extension"; GroupDescription: File extensions:
Root: HKCR; Subkey: ".q"; ValueType: string; ValueName: ""; ValueData: "qKDBsource"; Flags: uninsdeletevalue; Tasks: qAssociation 
Root: HKCR; Subkey: ".k"; ValueType: string; ValueName: ""; ValueData: "qKDBsource"; Flags: uninsdeletevalue; Tasks: kAssociation 
Root: HKCR; Subkey: "qKDBsource"; ValueType: string; ValueName: ""; ValueData: "q KDB source"; Flags: uninsdeletekey;
Root: HKCR; Subkey: "qKDBsource\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\QFILE.ICO"
Root: HKCR; Subkey: "qKDBsource\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\qStudio.exe"" ""%1"""

Combining into an ANT script

You want to

  1. Compile your JAR
  2. Create exes for both programs that point to the jar
  3. Place the exe’s into an installer

Like so (you need to install inno setup):

<launch4j configFile="src/main/resources/launch4j-qstudio.xml" />
<launch4j configFile="src/main/resources/launch4j-sqldashboards.xml" />
<exec dir="." executable="${INNO.SETUP.DIR}">
	<arg line="/cc '${basedir}\src\main\resources\windowsInstall.iss'" />
</exec >

Finished Installer

Can be found at

java , , , , , ,