I ran into an interesting problem today while working on a bash script (funny where we end up, isn't it?) to be run in Cygwin. For the life of me, I could not get the bash script to execute a JAR file. I kept getting an error along the lines of:
Unable to access jarfile batik-rasterizer.jar
Because I'm working from Cygwin, I assumed that I might need to add the path to that JAR file either in my .bashrc script or at least explicitly from the Cygwin command line. However, doing so didn't make any difference. My next guess was to include the absolute path to the JAR in the bash script, like so:
java -jar "/cygdrive/c/Program Files/batik-1.7/batik-rasterizer.jar" ...
However, that approach didn't work either. As a total long shot, I decided to try using a Windows file path as the argument to the above command, as opposed to the Cygwin-friendly path shown. Therefore, my new command ended up looking like:
java -jar "C:∖Program Files∖batik-1.7∖batik-rasterizer.jar" ...
Believe it or not, doing so did the trick and I was able to execute the JAR file from within my bash script. It seems really strange, since almost everything tends to require a Cygwin-friendly path in order to execute properly. But maybe since the JRE was installed for Windows rather than from within Cygwin itself, the hack makes more sense.
Comments
Post Comments
If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.
This isn't really a hack, just a silly incompatibility between Cygwin and normal Windows applications. Because it's a Windows JRE, the java executable has no idea how to use a Cygwin path. It's interesting, however, that things didn't work when specifying just the JAR filename. I'll bet that the JRE is looking for the %CD% environment variable to tell it the current working directory, which won't be set in a Cygwin shell.
Permalink