This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shell Question Re: Cygwin Product


Hi, Scott,

You are mixing environments when you use a bash shell to run java. Your java system is Windows based and expecting Windows conventions for paths, which are different from UNIX style. Also, path separators for one system have a different meaning on the other.

UNIX shells generally use the semicolon as a command separator:

$ ls; pwd

To get the new item into the classpath requires quoting. There are several ways to do so:

	CLASSPATH="${CLASSPATH};C:/somejar.jar"
	CLASSPATH=${CLASSPATH}';C:/somejar.jar'
	CLASSPATH=${CLASSPATH}\;C:/somejar.jar

Any one of these should work.

Also, when working with files in other directories, you may find you need to translate the UNIX path you're using into a windows path before java will correctly recognize it. You would use the cygpath command to do this. When I was doing this for a java class I took, I created a function to run java with the correct setup. I don't have it with me anymore, but the general idea was:

function java
{
	# Run java with converted paths, $1 MUST be a UNIX style path.
	/your/path/to/java $(cygpath -w $1)
}

This does not take into consideration issues of multiple arguments, possible options for java or paths that are already in Windows format, or any error conditions. You'll need to add those.

Bob

Scott Purcell wrote:
Hello,

I have been using the Cygwin product for a couple of months on my Win2000 box. I am having trouble understanding a few issues (or possible) limitations.

My box has a single C:/ drive. So whenever I use the cygwin shell window, I have to type paths such as:
rm -r /cygdrive/c/tmptrash

I have found myself using cygwin for some things and the cmd window for other things. Today I was compiling some java classes in which I always use the cygwin shell. (bash).
javac com/skp/package/abc.java

But I cannot run the class after I compile it.
java com.skp.package.abc
When I do the above, it never shows me any of the system out commands.

Also, when I am dealing with classpaths I am having issues:

spurcell@DSGSTL-PC-1523 /
$ echo $CLASSPATH
.;C:\lib\xmlrpc-1.1.jar;C:\lib\xerces.jar;C:\lib\saxpath.jar;C:\lib\jaxen-core.j
ar;C:\lib\jaxen-jdom.jar;C:\lib\jdom.jar;C:\lib\servlet.jar;C:\lib\altercast_sdk
.jar;C:\projects\src\java_src;C:\projects\enklav\WEB-INF\classes;C:\lib\oracle.j
ar;C:\lib\javamail.jar;C:\lib\jspsmart.jar;

spurcell@DSGSTL-PC-1523 /
It shows me the classpaths but with "PC" type backslashes. And when I try to add a new path, it never shows up in my update of classpath
CLASSPATH=${CLASSPATH};C:/somejar.jar

echo $CLASSPATH
(shows the above without the new somejar.jar)

Anyway, I believe I am not using cygwin like it should be. Could anyone take a few minutes out of their day to assist me?

Sincerely
Scott


-- 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/

-- Bob McGowan Staff Development Engineer VERITAS Software rmcgowan@veritas.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]