Gradle – Passing on the App Home Directory

Gradle’s ‘application’ plugin is cool enough to create start scripts for *nix and Windows platforms but doesn’t have an easy way pass on the app directory ( install path ). Knowing where your app is installed is pretty useful if you are writing for the desktop.

Here’s one hacky way to pass it on as a system property:

Reference –

JVisualVM via SSH Proxy

Java’s VisualVM is a handy tool if you want to monitor your JVM’s health. Here’s a nice script to quickly connect to your remote JVM over a SSH tunnel.

First, start your java app on your server with JMX enabled:

Run the following script from your local machine:


Always Use a Build Tool

Just started work on a personal project to learn some new frameworks and decided on using Spring + Jetty + MongoDB. I somehow managed to get Spring + Jetty working by going through some tutorials online but got stuck when it came to integrating MongoDB.

The most difficult task was resolving all the dependent jars. Most tutorials used maven to resolve dependencies but I didn’t use it as the XML style configuration was quite intimidating for me and so went out to resolve all dependencies manually by searching online and downloading them one by one as and when I encountered the NoClassDefFoundError, little did I know that this would be futile. After wasting several hours, got really frustrated and gave a shot at Gradle.

Oh boy! what a really elegant build tool after all .. this is all it took to resolve the dependencies


JavaScript Gotchas!

Stumbled upon this by accident:

The following JavaScript code …

.. will actually display



Apparently, it seems “The JavaScript DOM bindings allow indexing by HTML id” as explained at

Gosh! Even after so many years I never knew this 🙁

A quick and dirty logging in Java

If you are working on a really small app and too lazy to do proper logging but would still like to write all your logs (read sysouts) to a file then here is a quick and dirty trick.

Call the following method during the start of your application.

All System.out.println(…) will now be piped to a file myapp.log in your home directory.

Note that this is a dirty way of logging (a simple Google search should tell you why sysouts are bad ) and could easily get out of hand as your application grows. Use this only if your application is too small to be bothered about using a standard logging framework.