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:


OneClipboard… and How I Ended Up with this Blog

After nearly an year of procrastination I have finally managed to open source my tiny side project. Its a simple app that you install on your desktop and android device and voila! you can right click copy text on your PC and paste it on your android.

As with most side projects, I decided to write this app for self need. There were many times I wanted to copy some interesting link while browsing on my desktop and quickly message it to a friend on WhatsApp.

Initially my search on the play store didn’t bring up any good app that could sync clipboard text between multiple devices and so I quickly hacked up a solution which seemed to work well when all my devices ( desktop and android ) were on the same WiFi ( LAN ). Once I switched to 3G on my android phone, it no longer worked. It turned out that incoming connections on a port are blocked by ISPs ( more on this if you search for “reverse connection” or check this ).

I did some app hunting and found ClipSync which seemed more polished but it too worked only in a LAN. I figured out that the only way to make it work over the internet was to host a server that would maintain reverse connections from various devices and help communicate between them and this is how I ended up buying this domain and hosting and this blog :).

I do not yet have a release that people can just download and install easily, hope to do it soon. Until then please try it out from the source.

Git – The Lesser Known Skip-Worktree

When working on a project, there is almost certainly a stage where you would temporarily want to ignore changes in a file from being committed ( like a config file ). If you are using Git, the usually suggested option is ‘assume-unchanged’ as shown below

The problem with this option is that if you do a ‘git checkout .’ ( discarding changes in working tree ) then it will remove the changes in the file you have temporarily ignored also. A better solution is to use the ‘skip-worktree’ option

To remove this use


more info at –

more info at –


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.