How to use Junction if you want Symbolic links in Windows XP

Ever since I started developing using Unix machines I've wanted symbolic links in Windows XP.  A recent pursuit of backup solutions left me really wanting symbolic links so I started the search.  This blog post gave me everything I needed, using a tool from Microsoft's website called junction.

This command line tool created junction points between a symbolic name and a real folder on your hard drive (sorry network drives cannot be linked to).

I downloaded it and placed the junction.exe file in my C:\WINDOWS\system32 directory so it would be on my system path.

Below is my little walk-through of how to use junction.

I created a folder on my desktop called "junction test" and created a folder inside that called "folder":

I created a text file called "README.txt" inside the "folder" directory:

I opened a Windows DOS prompt (cmd) and navigated to the "junction test" folder on my desktop, then I ran the junction command like this:
junction "junction" folder

This gave the following output:
Junction v1.05 - Windows junction creator and reparse point viewer

Copyright (C) 2000-2007 Mark Russinovich

Systems Internals -

Created: C:\Documents and Settings\abeacock\Desktop\junction test\junction

Targetted at: C:\Documents and Settings\abeacock\Desktop\junction test\folder

And the folder now looked like this:

If I double-clicked on the "junction" folder this is what I saw:

So as you can see the contents of the "folder" directory is now available in via the "junction" directory as well.  Obviously the junction doesn't need to be next to the folder you want to link too (that would be of little use) but it can be anywhere on your harddrive (I was using it to point into my DropBox sync folder).


Only the junction tool knows that these folders are actually symbolic links, the rest of the Windows file system thinks they are normal folders. So for example you can simply delete the junctions via Windows and they go in your recycle bin and the folder that it points to stays where it was:


But if you then empty your recycle bin it also empties the contents of the folder that this junction was pointing at (which is probably NOT what you wanted to happen!):

So please remember to always use the junction command to create & delete junctions, you can also use it to show you which directories are actually junctions so you know if you should delete it or not, refer to the junction download page for more details.

It's a fantastic tool for Windows XP and very very handy for certain things but please bear in mind the warning above...

Technorati Tags: , , ,

Are your Maven profiles being picked up as 'default'?

We recently noticed that the profile that we had marked as default in our Maven settings.xml file was not being set as the default. Like many examples on the web we had the following XML element set in the appropriate profile:

After some searching we found this maven-users mailing list post detailing the solution.

<activeByDefault/> isn't enough to set the value, you need to explicitly set the boolean value to true:
Once we saved that change in our settings.xml file the profile was picked up as the default.

Technorati Tags: ,

A cool way to assert Lists using JUnit

I found this JUnit tip recently over on Joe Walnes's blog, a rather nifty (and different) way to assert whether two Lists contain the same items:

JUnit/TestNG tip: Diffing Lists

Technorati Tags: , ,