A largely unenjoyable couple of hours was spent tracking down a nasty little issue surrounding classpaths in cygwin. First a little background. On Windows, if you want to specify a classpath, @java@ expects it to be a series of semi-colon separated paths, like so:
On Unix, @java@ expects a colon separated list:
I’m playing around with using a shell script to run my app on windows, however I’m using cygwin as I hate writing bat files. This is a bit of a problem however – cygwin expects Unix format paths, but we’re still running a Windows version of @java@. Once I’d worked out that this is what was causing the strange
ClassNotFoundExceptions, a quick google turned up @cygpath@, which can translate from Windows to UNIX paths (and vice versa). So, when invoking @java@ in my shell script I just changed:
java -classpath $MYCLASSPATH org.package.MyClass
java -classpath `cygpath --path --windows $MYCLASSPATH` org.package.MyClass
Next up, I can change my script to work on Unix by conditionally invoking @cygpath@ only if I’m running in a cygwin bash shell.
Leave a Reply