WinRun4J 0.3.3 Released

A new version of WinRun4J is available. It contains the following fixes and new features:

  • Moved service name, description and controls accepted to INI file
  • Refactored Service interface and added AbstractService helper class
  • Implemented FileAssociations helper class
  • Greatly improved the Registry API
  • Option to log to console and file
  • Log file rolling
  • Fix for relative log file path

The Registry API has been refactored to be easier to use (no need to open/close).

The Service API is now also much easier to use, with an AbstractService class. This makes the example service implementation much simpler:

package org.boris.winrun4j.test;

import org.boris.winrun4j.AbstractService;
import org.boris.winrun4j.EventLog;
import org.boris.winrun4j.ServiceException;

/**
 * A basic service.
 */
public class ServiceTest extends AbstractService
{
    public int serviceMain(String[] args) throws ServiceException {
        int count = 0;
        while (!shutdown) {
            try {
                Thread.sleep(6000);
            } catch (InterruptedException e) {
            }

            if (++count % 10 == 0)
                EventLog.report("WinRun4J Test Service", 
                      EventLog.INFORMATION, "Ping");
        }

        return 0;
    }
}

The shutdown variable is set to true when the service is requested to close by the service control manager.

You can download the new version from the WinRun4J Sourceforge Site.

Twitter Backup Utility

The following is a simple tool I hacked together in Java that downloads your twitter statuses to a directory, to test out the new WinRun4J Plugin for Eclipse. I wrote a simple Java class and then exported it to a single fat executable (console version): TwitterBackup.exe.

Note that you need Java to run this application: You can download it from here.

If you run it without command line arguments you get:

Twitter Backup v0.1.0 @winrun4j

A backup utility for Twitter statuses.

TwitterBackup [-user <user>|-search <search>] -outdir <backup_dir> 
    [-limit #hours|day|week|month|year]

The -user option is simply your twitter user id.

The -search option is a search query (you probably want to put “quotes” around it).

The -outdir option is the directory you want the statuses saved into.

The -limit option sets a time/date limit on the history, so “day” only loads statuses for the last 24 hours. The #hours is a number of hours (e.g. -limit 4 only saves statuses from the last 4 hours).

Some examples:

TwitterBackup -user twitter -outdir C:/TEMP -limit 12

This will save the “twitter” user’s statuses from the last 12 hours to the directory C:/TEMP.

TwitterBackup -search "cool filter:links" -outdir C:/TEMP -limit day

This will save all search results for “cool filter:links” for the last 24 hours to the directory C:/TEMP.

The utility is also incremental so you can run it over and over again and it will only grab new statuses.

It is designed to be run as a scheduled task (e.g. setup a schedule task to run every week and use the -limit week option).

Each twitter status is saved into a separate file using the unique status id provided by twitter. It simply contains the RSS item XML.

You can download TwitterBackup here

Note that Twitter has limits on how much you can download at one time and how far back in time you can go.

BTW The utility should work as specified but the author accepts no responsibilities is something screws up. Use at your own risk.

Launcher File Double-Click in Explorer

The following is a potentially useful hack if you have plenty of different java apps you need to launch from explorer but don’t want to create separate launcher files for each launcher configuration file.

Using Windows file associations we create a new file association for *.winrun4j to the WinRun4J launcher. The command executed is the new WinRun4J --WinRun4J:ExecuteINI command added in the previous release.

The following registry script updates the appropriate entries:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.winrun4j]
@="WinRun4JLaunch"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.winrun4j\OpenWithList]

[HKEY_CLASSES_ROOT\.winrun4j\OpenWithList\WinRun4J.exe]

[HKEY_CLASSES_ROOT\WinRun4JLaunch]
@="WinRun4J Launcher Configuration"

[HKEY_CLASSES_ROOT\WinRun4JLaunch\DefaultIcon]
@="F:\\Development\\tools\\WinRun4J.exe"

[HKEY_CLASSES_ROOT\WinRun4JLaunch\shell]

[HKEY_CLASSES_ROOT\WinRun4JLaunch\shell\open]

[HKEY_CLASSES_ROOT\WinRun4JLaunch\shell\open\command]
@="F:\\Development\\tools\\WinRun4J.exe --WinRun4J:ExecuteINI %1"

This assumes that you have the latest version of the launcher saved into F:/Development/tools – if not just change the above entries to point to your folder.

The following screenshot shows a bunch of launcher files:

Now you can create any launch configuration and give it a .winrun4j extension and then double-click to launch.

Caveat: As per usual, make sure you backup your registry before modifying.

New Eclipse Plugin for WinRun4J

The initial version of the Eclipse Plugin for WinRun4J is now available from the WinRun4J SourceForge site.

The Update Site URL is: http://winrun4j.sourceforge.net

The main features of the addin are (as per the website):

  • Launch any Java Application with WinRun4J (via right-click or launch configuration)
  • Export your Java Application as a single Windows Executable (with necessary jars embedded)
  • Provides improved windows integration from Eclipse (eg. JNI access to Registry).

To install the plugin in eclipse go to Help->Software Updates… then select Add Site… then
add http://winrun4j.sourceforge.net and click OK. The select “WinRun4J Eclipse Plugin 0.1.0” and click Install… and follow the prompts.

Further help on using the plugin is on the plugin website