path separator

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

path separator

samitj
Hi,
what is the path separator in Cygwin for paths, classpaths etc..

this works...
$ java -cp lib/matrix/matrix.jar com.test.matrix.simulation.SimulationApplication

this fails..

$ java -cp lib/matrix/matrix.jar:bin/ com.test.matrix.simulation.SimulationApplication
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/matrix/simulation/SimulationApplication

Can you please advise on this?

thanks,
Sam
Reply | Threaded
Open this post in threaded view
|

Re: path separator

Mark J. Reed-2
On Fri, Jun 6, 2008 at 9:17 PM, samitj <[hidden email]> wrote:
>
> Hi,
> what is the path separator in Cygwin for paths, classpaths etc..
>
> this works...
> $ java -cp lib/matrix/matrix.jar
> com.test.matrix.simulation.SimulationApplication

Java is not a Cygwin package.  You must be running the standard
Windows Java, which means you need to use Windows CLASSPATH syntax.

 Cygwin doesn't do any magic; stuff that wasn't compiled for Cygwin is
not going to behave differently just because you run it from a Cygwin
bash shell. :)


--
Mark J. Reed <[hidden email]>

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

Reply | Threaded
Open this post in threaded view
|

Re: path separator

René Berber-2
In reply to this post by samitj
samitj wrote:

> what is the path separator in Cygwin for paths, classpaths etc..
>
> this works...
> $ java -cp lib/matrix/matrix.jar
> com.test.matrix.simulation.SimulationApplication
>
> this fails..
> $ java -cp lib/matrix/matrix.jar:bin/
> com.test.matrix.simulation.SimulationApplication
> Exception in thread "main" java.lang.NoClassDefFoundError:
> com/test/matrix/simulation/SimulationApplication
>
> Can you please advise on this?

java is not a Cygwin program, it's a Windows program so it uses Windows
notation (or their own if they choose to change it).

In Windows the classpath separator is ';'

$ java -h
Usage: java [-options] class [args...]
            (to execute a class)
    or  java [-options] -jar jarfile [args...]
            (to execute a jar file)

where options include:
     -client       to select the "client" VM
     -server       to select the "server" VM
     -hotspot      is a synonym for the "client" VM  [deprecated]
                   The default VM is client.

     -cp <class search path of directories and zip/jar files>
     -classpath <class search path of directories and zip/jar files>
*------------->   A ; separated list of directories, JAR archives,
                   and ZIP archives to search for class files.
...
--
René Berber


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

Reply | Threaded
Open this post in threaded view
|

Re: path separator

samitj
In reply to this post by Mark J. Reed-2
hmm... i thought cygwin emulates a unix shell in windows.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/system32:/cygdri.....

anyway, if i use a windows separator (;), it doesnt work and it considers it the end of the command as per unix shell behavior.

dont know if u r trying to say something different, do u have a solution to make that work ?

Mark J. Reed-2 wrote
On Fri, Jun 6, 2008 at 9:17 PM, samitj <jain.samit@gmail.com> wrote:
>
> Hi,
> what is the path separator in Cygwin for paths, classpaths etc..
>
> this works...
> $ java -cp lib/matrix/matrix.jar
> com.test.matrix.simulation.SimulationApplication

Java is not a Cygwin package.  You must be running the standard
Windows Java, which means you need to use Windows CLASSPATH syntax.

 Cygwin doesn't do any magic; stuff that wasn't compiled for Cygwin is
not going to behave differently just because you run it from a Cygwin
bash shell. :)


--
Mark J. Reed <markjreed@gmail.com>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
Reply | Threaded
Open this post in threaded view
|

RE: path separator

Gary R. Van Sickle
> From: samitj
> Subject: Re: path separator
>
>
> hmm... i thought cygwin emulates a unix shell in windows.
> $ echo $PATH
> /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOW
> S/system32:/cygdri.....
>
> anyway, if i use a windows separator (;), it doesnt work and
> it considers it the end of the command as per unix shell behavior.
>
> dont know if u r trying to say something different, do u have
> a solution to make that work ?
>

PATH under Cygwin uses ':' as the separator.  Cygwin reads Windows' PATH env
var and replaces the ';'s with ':'s for its own use and any child Cygwin
processes.  There's more magic happening but that's most of what you care
about here.

No such special treatment is given CLASSPATH, since as others have already
pointed out, this is not anything that's any sort of standard.  It's an
environment variable that the native Windows executable java.exe uses for
its own purposes.  As such Cygwin leaves it untouched.

If you're trying to set CLASSPATH in a (Cygwin) shell script, you'll have to
quote it so the ';'s don't get misinterpreted like you've discovered.  Hit
the Googles for "shell quoting" and settle in for a long night of reading.

--
Gary R. Van Sickle


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

Reply | Threaded
Open this post in threaded view
|

Re: path separator

Subrata Biswas
In reply to this post by samitj
The following 2 steps worked for me

1) Use semicolon as path separator
2) Enclose the whole path string inside double quote

Example

javac -classpath ".;poi-3.2-FINAL-20081019.jar" SR.java