fjar, cygwin and console2
I didn’t write here for a long time – in part because I left my old job in ITC Networks and I had to get used to my new position in IBM but also because I had to finish my SCEA assignment. So now, since I’m a certified Sun Certified Enterprise Architect, I can start again to post here..
Due to my recent job change I’m forced to use Windows XP for a while (one year, I expect). I’m missing some of the tools from Linux and it’s stability. However, I started to find alternatives on Windows for most of the Linux tools I used.
One of the tools that helped me very much when developing Java applications on Linux was fjar.sh. This script will search for each occurrence of a Java class in a folder (searches the jars present in that folder). This is very useful when you know you need a class but you don’t know in which jar it is.
So I had to find a way to make this script work on windows as well (you’ll need to install Cygwin and Console2 to follow the instructions in this post). Enough talking .. here is is:
1) Console2 changes
Create a tab in Console2 with sh as shell. Make sure you add a “–login -i” after it. This way the bash will read the configuration as if it comes from a login process. This will allow you to specify your environment variables in Cygwin only and not mess with the Windows ones.
For me, the shell command looks like this: D:\cygwin\bin\sh.exe –login -i
The -i above makes the shell interactive (basically this helped me to stop the script once it found the file I need)
2) Changes in Cygwin
Create a sh script file in your Cygwin etc/profile.d folder to contain the following:
PATH=/cygdrive/d/cygwin/bin/:$PATH
export PATH
This will ensure that the version of find used by fjar utility is the one from Cygwin, not the one from Windows.
3) Changes in fjar.sh script
One more step now: modify the method doSearch() in fjar.sh utility as follows:
Change the line:
jar tf “$2″ | grep $grepargs “$1″ >$tmpfile
to:
jar tf `cygpath -m “$2″` | grep $grepargs “$1″ >$tmpfile
The change above will send a well-formed path to the jar utility.
Enjoy !