Wednesday, December 09, 2009

Unable to access jarfile on Cygwin

Today I ran into a strange problem on Cygwin: I give the full path to the jar file for the java command, but strangely, the java runtime shows me the error message: Unable to access jarfile /cygdrive/c/pathtojar/.yuicompressor.jar. What is going on? did I have a typo? No. Then Why? After scratch my head enough, I figure out that the java in Cygwin does not like Unix format path to specify the jar file. You can use cygpath to do the trick to convert the Unix format path to mixed(-m) or windows format(-w) path, the java command will happily take it and use the jar file. Here are the two commands that works for me:
  • java -jar `cygpath -m /cygdrive/c/pathtojar/.yuicompressor.jar`
  • java -jar `cygpath -w /cygdrive/c/pathtojar/.yuicompressor.jar`

pip install python packages makes it easy

pip is easy_install replacement, and it is easy to use. Here are some features I recently used:
  1. To install something from Python Package Index, for example, Django 1.1, you just issue: pip install django, it will download it and install it.
  2. To see what Python Packages were installed by pip, you can use command: pip freeze, of course, you can redirect the output to a file and pass around.
  3. To uninstall a Python Package, for example, Django 1.1 installed in step 1, the command is: pip uninstall django.
  4. To install some Python Package you may run into error: No distributions at all found for xxxxx, you can supply the package file url to the pip install command, for example, if you want to install Django 0.96.5, here is the command: pip install http://www.djangoproject.com/download/0.96.5/tarball/, this one is pretty cool, if you can find the package gz file, then you can install it by using pip.