Simple .cmd file works under Cygwin but not Window's cmd interpreter.

Andy Hall fixpertise-consulting@comcast.net
Sat Mar 5 16:33:00 GMT 2016


This is a puzzle that I have not been able to sort out despite trying all sorts of variations.  Basically,  I maintain a
bunch of Crystal Reports  based on Crystal reports XI R2.  Sorry,  I have no choice there.    I have this installed and
running on a Widows 10 machine.   How I did that is another story.   Recently I was asked what it would take to
internationalize these reports.  Fortunately, CR has a mechanism that allows you to define your own functions that can
be used in reports which  allow you to access properties files containing the localized entities just as you would for a
normal Java app.   All well and good. 

So I set about trying to get this to work.   The plugin to CR XI R2, is not well integrated with the base system and a
bit of not so nice manual configuration is necessary.  You have to follow this to the letter, but that is not
sufficient.   Out of the box I could not get it to work.    So to debug what was going on I wrote a simple bash script
to try to get it to work.   Lo and behold this simple script works:

#!/bin/bash

echo " "
echo "CLASSPATH = $CLASSPATH"
echo " "
#JAVA_HOME=C":\Program Files (x86)\Java\jdk1.6.0_45"
echo "JAVA_HOME = $JAVA_HOME"
echo " "
echo "PATH = $PATH"

cd "/cygdrive/c/Program Files (x86)/Business Objects/Crystal Reports 11.5"
java -version
crw32.exe

Notice that this seem to do nothing but display some key variables and the run CR in its installation  directory, just
as the normal shortcut does.  It launches CR which finds the plugin and loads it.

Now I have a need to do the same outside of the Cygwin environment, so I wrote a simple equivalent .cmd file:

@Echo off

:: Display CLASSPATH
set CLASSPATH

:: Set and display JAVA_HOME
::set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
set JAVA_HOME

:: Add 32-bit JDK to PATH and display
::set PATH=%JAVA_HOME%\bin;%PATH%
set PATH

pushd C:\Program Files (x86)\Business Objects\Crystal Reports 11.5
java.exe -version
crw32.exe
popd

If I run this from a bash command prompt it works as well.  It also works if I launch cmd from bash and then run the cmd
file.  That makes sense.

But here is the puzzle,   If I simply click on the runCR.cmd file, say from  the file explorer,  CR launches but does
not find the plugin.  The same happens if I launch a Windows cmd window and run the cmd file outside of Cygwin. 

So the question is: “What could possibly be the difference between the Cygwin environment and the Windows cmd
environment that makes this work in one and not the other?”   I have examined the PATH used in the Cygwin environment
and set the PATH in the Windows environment to be identical.  No change.   I thought it might have to do with whether or
not a 32-bit or 64-bit JVM is configured in the path, but that does not seem to make a difference.   It fails if the JVM
in the path is 32-bit or 64-bit probably because CR really gets its JVM from a registry setting.

I am at a loss,   Does anybody have an idea?   

BTW, I would have expected the reverse to be the case:  works in Windows but not Cygwin.  

Andy Hall



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list