public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* HELP: java path and classpath question
@ 2002-02-11 10:45 wally liau
  2002-02-11 11:06 ` Larry Hall (RFK Partners, Inc)
  2002-02-11 11:11 ` Randall R Schulz
  0 siblings, 2 replies; 7+ messages in thread
From: wally liau @ 2002-02-11 10:45 UTC (permalink / raw)
  To: cygwin

I am having a problem compiling generic java source
file with following settings: 

alias gjc='java -ms12m gjc.Main -bootclasspath
$GJ_HOME/classes:/cygdrive/c/jdk1.3.1_01/jre/lib/rt.jar:/cygdrive/c/jdk1.3.1_01/jre/lib/i18n.jar'


export JAVA_HOME=/cygdrive/c/jdk1.3.1_01
export GJ_HOME=/cygdrive/c/Programs/gj

The error messages show that cygwin can't find java
class (eg, it can't find String class). However,
compiling stardard java code using "javac" works fine.
I guess there may be some problems with how to set up
paths and hope someone out there could help me to fix
it. Thanks a lot. 

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-11 10:45 HELP: java path and classpath question wally liau
@ 2002-02-11 11:06 ` Larry Hall (RFK Partners, Inc)
  2002-02-11 11:11 ` Randall R Schulz
  1 sibling, 0 replies; 7+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2002-02-11 11:06 UTC (permalink / raw)
  To: wally liau, cygwin

At 01:45 PM 2/11/2002, wally liau wrote:
>I am having a problem compiling generic java source
>file with following settings: 
>
>alias gjc='java -ms12m gjc.Main -bootclasspath
>$GJ_HOME/classes:/cygdrive/c/jdk1.3.1_01/jre/lib/rt.jar:/cygdrive/c/jdk1.3.1_01/jre/lib/i18n.jar'
>
>
>export JAVA_HOME=/cygdrive/c/jdk1.3.1_01
>export GJ_HOME=/cygdrive/c/Programs/gj
>
>The error messages show that cygwin can't find java
>class (eg, it can't find String class). However,
>compiling stardard java code using "javac" works fine.
>I guess there may be some problems with how to set up
>paths and hope someone out there could help me to fix
>it. Thanks a lot. 


Check the email archives for issues about Java and Cygwin paths.  The 
simple answer is that Java doesn't understand Cygwin paths unless you're
running a Cygwin version of Java (I doubt that's the case unless there is 
a Cygwin version out there that this list doesn't know about - a 
possibility I'll concede but unlikely).  You need to use Win32 paths with
Win32 Java.



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
838 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-11 10:45 HELP: java path and classpath question wally liau
  2002-02-11 11:06 ` Larry Hall (RFK Partners, Inc)
@ 2002-02-11 11:11 ` Randall R Schulz
  2002-02-11 14:39   ` wally liau
  1 sibling, 1 reply; 7+ messages in thread
From: Randall R Schulz @ 2002-02-11 11:11 UTC (permalink / raw)
  To: wally liau, cygwin

Wally,

[ For those of us doing Java programming under Cygwin, this has become a 
FAQ and there are messages in the Cygwin mail archive that cover it. ]


Please give us more information about what happens. Specifically, what 
commands are you issuing. Tell us what program you're invoking (since your 
alias invokes the "java" command via the PATH, tell us what PATH is so we 
know which java command is being executed). Tell us what error message(s) 
result.


After I see through the confusing names that suggest that you're using the 
Gnu Java Compiler (which, as far as I know, is not yet available for 
Cygwin), it appears that at least part of your problem (quite possibly all 
of it) is that you're using POSIX-style class-path syntax when in fact 
you're invoking a Windows Java VM and hence must use a Windows-style 
class-path (semicolons separating the components and Windows-style full 
names, not Cygwin / POSIX -style). This applies both to the CLASSPATH 
environment variable and the various file name and class-path arguments to 
the JVM / JRE and Java compiler (all the Sun JDK and / or JRE executables, 
in fact).

If you're unaware of how to accommodate this, look into the "cygpath" 
command. It translates path names between POSIX and Windows formats. It can 
operate on an individual file name or PATH variable-like strings. There's 
no man page, use "cygpath --help".

For your own convenience, I suggest you write some wrapper scripts that 
obscure the need for Windows file name and path formats by transforming 
Cygwin-style arguments to their Windows equivalents for you. Otherwise your 
makefiles and other build scripts lose their portability to other POSIX 
environments. I use a generic script that I link (hard or symbolic) to a 
file with the same name as the target command. That way I achieve complete 
transparency and / or compatibility with native POSIX environments such as 
Solaris, Linux or *BSD and need only make a new link should a new tool be 
added to the Java SDK.

Randall Schulz
Mountain View, CA USA


At 10:45 2002-02-11, wally liau wrote:
>I am having a problem compiling generic java source file with following 
>settings:
>
>alias gjc='java -ms12m gjc.Main -bootclasspath
>$GJ_HOME/classes:/cygdrive/c/jdk1.3.1_01/jre/lib/rt.jar:/cygdrive/c/jdk1.3.1_01/jre/lib/i18n.jar'
>
>
>export JAVA_HOME=/cygdrive/c/jdk1.3.1_01
>export GJ_HOME=/cygdrive/c/Programs/gj
>
>The error messages show that cygwin can't find java class (eg, it can't 
>find String class). However, compiling stardard java code using "javac" 
>works fine. I guess there may be some problems with how to set up paths 
>and hope someone out there could help me to fix it. Thanks a lot.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-11 11:11 ` Randall R Schulz
@ 2002-02-11 14:39   ` wally liau
  2002-02-11 16:09     ` Randall R Schulz
  0 siblings, 1 reply; 7+ messages in thread
From: wally liau @ 2002-02-11 14:39 UTC (permalink / raw)
  To: Randall R Schulz, cygwin

He Randall, thanks a lot for the message. 

The java compiler I am using is called generic java
(with extended utility classes, see
http://www.research.avayalabs.com/user/wadler/pizza/gj/and
http://developer.java.sun.com/developer/earlyAccess/adding_generics/).


those environment variables and alias are set in
.bashrc. "gjc" is supposed to compile java source
files containing templates into stardard class files. 

I am confused with cygwin- and window-style paths. A
simple question is which style to use in order to
invoke window java vm, and if window-style path is the
one to be used, how to put it in a file like .bashrc. 

Thanks again. 

I think you are right about 
--- Randall R Schulz <rrschulz@cris.com> wrote:
> Wally,
> 
> [ For those of us doing Java programming under
> Cygwin, this has become a 
> FAQ and there are messages in the Cygwin mail
> archive that cover it. ]
> 
> 
> Please give us more information about what happens.
> Specifically, what 
> commands are you issuing. Tell us what program
> you're invoking (since your 
> alias invokes the "java" command via the PATH, tell
> us what PATH is so we 
> know which java command is being executed). Tell us
> what error message(s) 
> result.
> 
> 
> After I see through the confusing names that suggest
> that you're using the 
> Gnu Java Compiler (which, as far as I know, is not
> yet available for 
> Cygwin), it appears that at least part of your
> problem (quite possibly all 
> of it) is that you're using POSIX-style class-path
> syntax when in fact 
> you're invoking a Windows Java VM and hence must use
> a Windows-style 
> class-path (semicolons separating the components and
> Windows-style full 
> names, not Cygwin / POSIX -style). This applies both
> to the CLASSPATH 
> environment variable and the various file name and
> class-path arguments to 
> the JVM / JRE and Java compiler (all the Sun JDK and
> / or JRE executables, 
> in fact).
> 
> If you're unaware of how to accommodate this, look
> into the "cygpath" 
> command. It translates path names between POSIX and
> Windows formats. It can 
> operate on an individual file name or PATH
> variable-like strings. There's 
> no man page, use "cygpath --help".
> 
> For your own convenience, I suggest you write some
> wrapper scripts that 
> obscure the need for Windows file name and path
> formats by transforming 
> Cygwin-style arguments to their Windows equivalents
> for you. Otherwise your 
> makefiles and other build scripts lose their
> portability to other POSIX 
> environments. I use a generic script that I link
> (hard or symbolic) to a 
> file with the same name as the target command. That
> way I achieve complete 
> transparency and / or compatibility with native
> POSIX environments such as 
> Solaris, Linux or *BSD and need only make a new link
> should a new tool be 
> added to the Java SDK.
> 
> Randall Schulz
> Mountain View, CA USA
> 
> 
> At 10:45 2002-02-11, wally liau wrote:
> >I am having a problem compiling generic java source
> file with following 
> >settings:
> >
> >alias gjc='java -ms12m gjc.Main -bootclasspath
>
>$GJ_HOME/classes:/cygdrive/c/jdk1.3.1_01/jre/lib/rt.jar:/cygdrive/c/jdk1.3.1_01/jre/lib/i18n.jar'
> >
> >
> >export JAVA_HOME=/cygdrive/c/jdk1.3.1_01
> >export GJ_HOME=/cygdrive/c/Programs/gj
> >
> >The error messages show that cygwin can't find java
> class (eg, it can't 
> >find String class). However, compiling stardard
> java code using "javac" 
> >works fine. I guess there may be some problems with
> how to set up paths 
> >and hope someone out there could help me to fix it.
> Thanks a lot.
> 


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-11 14:39   ` wally liau
@ 2002-02-11 16:09     ` Randall R Schulz
  2002-02-17 13:11       ` rich-paul
  0 siblings, 1 reply; 7+ messages in thread
From: Randall R Schulz @ 2002-02-11 16:09 UTC (permalink / raw)
  To: wally liau, cygwin

Wally,

Unless a program has been ported to and compiled with Cygwin headers and 
libraries it is a Windows program and knows nothing of POSIX (Unix-style) 
file names and PATH (-type) variables. Cygwin programs will understand both 
kinds of arguments. To be more precise, the Cygwin libraries take either 
kind of file name, but a program that was only minimally ported to Cygwin 
might make its own assumptions about what a file name looks like, and could 
misinterpret a Windows-style name.

The Java tools from Sun have _not_ been ported to Cygwin, and hence you 
must supply arguments in the Windows format.

Good luck.

Randy


At 14:39 2002-02-11, you wrote:
>He Randall, thanks a lot for the message.
>
>The java compiler I am using is called generic java (with extended utility 
>classes, see http://www.research.avayalabs.com/user/wadler/pizza/gj/and 
>http://developer.java.sun.com/developer/earlyAccess/adding_generics/).
>
>
>those environment variables and alias are set in .bashrc. "gjc" is 
>supposed to compile java source files containing templates into stardard 
>class files.
>
>I am confused with cygwin- and window-style paths. A simple question is 
>which style to use in order to invoke window java vm, and if window-style 
>path is the one to be used, how to put it in a file like .bashrc.
>
>Thanks again.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-11 16:09     ` Randall R Schulz
@ 2002-02-17 13:11       ` rich-paul
  2002-02-17 17:02         ` Randall R Schulz
  0 siblings, 1 reply; 7+ messages in thread
From: rich-paul @ 2002-02-17 13:11 UTC (permalink / raw)
  To: Randall R Schulz, cygwin

My suggestion is a simple patch and recompile to cygwin.  There
is a file called environ.cc.  It contains the code that
automaticly converts variables like PATH and HOME to cygwinformat
when it enters cygwin, and back when it leaves.

All you have to do is add the code preceded by the plus signs code right after
the path entry, on about line 50 of the file:


 static win_env conv_envvars[] =
   {
     {"PATH=", 5, NULL, NULL, cygwin_win32_to_posix_path_list,
      cygwin_posix_to_win32_path_list,
      cygwin_win32_to_posix_path_list_buf_size,
      cygwin_posix_to_win32_path_list_buf_size},
+     {"CLASSPATH=", 10, NULL, NULL, cygwin_win32_to_posix_path_list,
+      cygwin_posix_to_win32_path_list,
+      cygwin_win32_to_posix_path_list_buf_size,
+      cygwin_posix_to_win32_path_list_buf_size},
     {"HOME=", 5, NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
     return_MAX_PATH, return_MAX_PATH},
    {"LD_LIBRARY_PATH=", 16, NULL, NULL, cygwin_conv_to_full_posix_path,
     cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
    {"TMPDIR=", 7, NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
     return_MAX_PATH, return_MAX_PATH},
    {"TMP=", 4, NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
     return_MAX_PATH, return_MAX_PATH},
    {"TEMP=", 5, NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
     return_MAX_PATH, return_MAX_PATH},
    {NULL, 0, NULL, NULL, NULL, NULL, 0, 0}
  };


Note that I just cut and pasted the entry for PATH, and changed the word PATH to CLASSPATH, and the number 5 following ( which is the length, including the equals sign) to 10.  If you want to add other variables, feel free.  I compile using vc++, so I added the INCLUDES and LIBS variables as well.

I have tried to get them to include this patch, or even better to make the
environment processing configurable, but to no avail.  :(


On Mon, Feb 11, 2002 at 04:09:39PM -0800, Randall R Schulz wrote:
> Wally,
> 
> Unless a program has been ported to and compiled with Cygwin headers and 
> libraries it is a Windows program and knows nothing of POSIX (Unix-style) 
> file names and PATH (-type) variables. Cygwin programs will understand both 
> kinds of arguments. To be more precise, the Cygwin libraries take either 
> kind of file name, but a program that was only minimally ported to Cygwin 
> might make its own assumptions about what a file name looks like, and could 
> misinterpret a Windows-style name.
> 
> The Java tools from Sun have _not_ been ported to Cygwin, and hence you 
> must supply arguments in the Windows format.
> 
> Good luck.
> 
> Randy
> 
> 
> At 14:39 2002-02-11, you wrote:
> >He Randall, thanks a lot for the message.
> >
> >The java compiler I am using is called generic java (with extended utility 
> >classes, see http://www.research.avayalabs.com/user/wadler/pizza/gj/and 
> >http://developer.java.sun.com/developer/earlyAccess/adding_generics/).
> >
> >
> >those environment variables and alias are set in .bashrc. "gjc" is 
> >supposed to compile java source files containing templates into stardard 
> >class files.
> >
> >I am confused with cygwin- and window-style paths. A simple question is 
> >which style to use in order to invoke window java vm, and if window-style 
> >path is the one to be used, how to put it in a file like .bashrc.
> >
> >Thanks again.
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 

-- 
Got freedom?  Vote Libertarian:  http://www.lp.org

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: HELP: java path and classpath question
  2002-02-17 13:11       ` rich-paul
@ 2002-02-17 17:02         ` Randall R Schulz
  0 siblings, 0 replies; 7+ messages in thread
From: Randall R Schulz @ 2002-02-17 17:02 UTC (permalink / raw)
  To: rich-paul, cygwin

Paul,

Whenever I see a hard-coded list of arbitrary values like that, I usually 
conclude there is a need for an externally controlled way to specify that 
list of values.

If I were going to go in and muck around with this code, I'd add a variable 
such as CYGPATHVARS or some such (naming rights go to the coder, of course) 
which took the form of a <somehow>-deliminted list of environment variable 
names which were to be transformed between Windows and POSIX path syntax as 
they passed in and out of the Cygwin world, as it were.

I see from the context of the patch you included there is a mix of 
PATH-like and single-name variables. I guess that might require either some 
special detection code during conversion or two separate control variables, 
one for the PATH-like variables one for the single-name ones.

I can see why a Java-specific patch would be rejected, but not a generic 
one. Did you submit a generic solution, and if so, what reason did you get 
for it being rejected? Was it rejected by the BASH principals or by the 
Cygwin principals?

Anyway, since my generic wrapper script works adequately for my needs, I'm 
content with the current situation.

Randall Schulz
Mountain View, CA USA


At 13:02 2002-02-17, rich-paul@rich-paul.net wrote:
>My suggestion is a simple patch and recompile to cygwin.  There
>is a file called environ.cc.  It contains the code that
>automaticly converts variables like PATH and HOME to cygwinformat
>when it enters cygwin, and back when it leaves.
>
>All you have to do is add the code preceded by the plus signs code right after
>the path entry, on about line 50 of the file:
>
>
>  static win_env conv_envvars[] =
>    {
>      {"PATH=", 5, NULL, NULL, cygwin_win32_to_posix_path_list,
>       cygwin_posix_to_win32_path_list,
>       cygwin_win32_to_posix_path_list_buf_size,
>       cygwin_posix_to_win32_path_list_buf_size},
>+     {"CLASSPATH=", 10, NULL, NULL, cygwin_win32_to_posix_path_list,
>+      cygwin_posix_to_win32_path_list,
>+      cygwin_win32_to_posix_path_list_buf_size,
>+      cygwin_posix_to_win32_path_list_buf_size},
>      {"HOME=", 5, NULL, NULL, cygwin_conv_to_full_posix_path, 
> cygwin_conv_to_full_win32_path,
>      return_MAX_PATH, return_MAX_PATH},
>     {"LD_LIBRARY_PATH=", 16, NULL, NULL, cygwin_conv_to_full_posix_path,
>      cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
>     {"TMPDIR=", 7, NULL, NULL, cygwin_conv_to_full_posix_path, 
> cygwin_conv_to_full_win32_path,
>      return_MAX_PATH, return_MAX_PATH},
>     {"TMP=", 4, NULL, NULL, cygwin_conv_to_full_posix_path, 
> cygwin_conv_to_full_win32_path,
>      return_MAX_PATH, return_MAX_PATH},
>     {"TEMP=", 5, NULL, NULL, cygwin_conv_to_full_posix_path, 
> cygwin_conv_to_full_win32_path,
>      return_MAX_PATH, return_MAX_PATH},
>     {NULL, 0, NULL, NULL, NULL, NULL, 0, 0}
>   };
>
>
>Note that I just cut and pasted the entry for PATH, and changed the word 
>PATH to CLASSPATH, and the number 5 following ( which is the length, 
>including the equals sign) to 10.  If you want to add other variables, 
>feel free.  I compile using vc++, so I added the INCLUDES and LIBS 
>variables as well.
>
>I have tried to get them to include this patch, or even better to make the
>environment processing configurable, but to no avail.  :(
>
>
>On Mon, Feb 11, 2002 at 04:09:39PM -0800, Randall R Schulz wrote:
> > Wally,
> >
> > Unless a program has been ported to and compiled with Cygwin headers and
> > libraries it is a Windows program and knows nothing of POSIX (Unix-style)
> > file names and PATH (-type) variables. Cygwin programs will understand 
> both
> > kinds of arguments. To be more precise, the Cygwin libraries take either
> > kind of file name, but a program that was only minimally ported to Cygwin
> > might make its own assumptions about what a file name looks like, and 
> could
> > misinterpret a Windows-style name.
> >
> > The Java tools from Sun have _not_ been ported to Cygwin, and hence you
> > must supply arguments in the Windows format.
> >
> > Good luck.
> >
> > Randy


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-02-18  1:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-11 10:45 HELP: java path and classpath question wally liau
2002-02-11 11:06 ` Larry Hall (RFK Partners, Inc)
2002-02-11 11:11 ` Randall R Schulz
2002-02-11 14:39   ` wally liau
2002-02-11 16:09     ` Randall R Schulz
2002-02-17 13:11       ` rich-paul
2002-02-17 17:02         ` Randall R Schulz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).