This is the mail archive of the
mailing list for the Cygwin project.
Re: Question on Java and Cygwin
On 7/30/2010 2:16 PM, Ernest Mueller wrote:
> Am trying to use Java file.io without shelling out all the time. To use
> cygpath you basically have to spawn shells to do any IO commands, which is
> not a best practice.
With that out of the way, what exactly are you trying to do? Are you
trying to open files whose paths are POSIX paths, or are you trying to
create paths which you need to hand off to Cygwin processes? Another
way of phrasing this is: is your program being called *from* Cygwin or
is it trying to call *into* Cygwin? In the former case, those POSIX
paths can be converted by whatever is calling your Java program prior to
handing off the paths. There would be no extra shell-out for that in
most cases. In the latter case, you are already shelling out to call
the Cygwin process, so you can integrate the call there to avoid an
The problem you're facing is common for Windows applications (of which
Java applications are members) integrating with Cygwin applications.
The "ant" script shipped with Apache Ant has some good examples of how
to ensure that POSIX paths are handed off to Java correctly. I can't
think of a good example offhand for calling into Cygwin, but you can
often handle that most simply by creating a script to use as a shim for
converting your paths prior which then goes on to call the script or
program you really need to run.
If there is still confusion, perhaps you could include a short snippet
of code which demonstrates what you want to do.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple