QuickTip: Running Java with Classpath in Cygwin

If you are running a Java program and your classpath is in UNIX separator style (‘/’ instead of ”), you may be in trouble as java.exe is Windows specific executable which understands Windows separator and not UNIX style separator. To circumvent this issue in your shell script you can use the following:

java -cp `cygpath -wp $CLASSPATH`

instead of


java -cp $CLASSPATH

Tagged with: ,
Posted in QuickTip
One comment on “QuickTip: Running Java with Classpath in Cygwin
  1. Hi,

    Its worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue. to read more about How classpath works in Java

    Thanks
    Javin
    FIX Protocol Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CommentLuv badge

Welcome to Sampreshan
Technology Strategist, Speaker, Scrum/XP/Agile Trainer Coach and Trainer
Your interest areas
Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: