How to run Java from Cygwin How to run Java from Cygwin bash bash

How to run Java from Cygwin


  • Java classpath uses semicolon as the token separator.
  • Use backticks instead of single quotes

Try:

java -classpath `cygpath -u "/cygdrive/c/Projects/common/lib/rome-1.0.jar;/cygdrive/c/Projects/common/lib/jdom-1.0.jar;/cygdrive/c/Projects/common/lib/jsoup-1.6.1.jar;/cygdrive/c/Projects/common/lib/mysql-connector-java-5.1.18-bin.jar;/cygdrive/c/Projects/Freereader/bin/"` com.free.syndication.SQLfeeder


  • In bash, the syntax $(command) is clearer than the backticks `command`
  • cygpath has a -p option to convert PATH-like values (as opposed to single path names) between Windows and Unix, i.e.
    • cygpath -pu 'C:\Users\me\bin;C:\Users\me\project\bin' will give /cygdrive/c/Users/me/bin:/cygdrive/c/Users/me/project/bin
    • cygpath -pw will do the same in the opposite direction

Note that cygpath -u "/cygdrive/c" (as in your question) will not change anything, since the directory name is already in the desired (Unix) syntax. You could omit it just as well.

So, the command becomes:

CP="C:/Projects/common/lib/rome-1.0.jar;C:/Projects/common/lib/jdom-1.0.jar;C:/Projects/common/lib/jsoup-1.6.1.jar;C:/Projects/common/lib/mysql-connector-java-5.1.18-bin.jar;C:/Projects/Freereader/bin"# for a Windows Java binary:java -classpath "$(cygpath -pw "$CP")" com.free.syndication.SQLfeeder # for a Unix Java binary:java -classpath "$(cygpath -pu "$CP")" com.free.syndication.SQLfeeder 

Alternatively, you can start with a Unix-style class path, but the commands stay the same. In either case, you can of course omit the call to cygpath if the class path is already in the desired syntax.


Don't you need backticks?

java -classpath `cygpath -u "/cygdrive/c/Projects/common/lib/rome-1.0.jar:/cygdrive/c/Projects/common/lib/jdom-1.0.jar:/cygdrive/c/Projects/common/lib/jsoup-1.6.1.jar:/cygdrive/c/Projects/common/lib/mysql-connector-java-5.1.18-bin.jar:/cygdrive/c/Projects/Freereader/bin/"` com.free.syndication.SQLfeeder