tags:

views:

685

answers:

5

I want to start nutch from Java. How can I start cygwin from a Java program?

+1  A: 

Rather than use Java to start Cygwin in order to invoke nutch you should probably look into integrating Nutch directly with your Java app. There's some documentation here:

"While the Nutch web app is a great way to get started with search, most projects using Nutch require the search function to be more tightly integrated with their application. There are various ways to achieve this, depending on the application. The two ways we'll look at here are using the Nutch API and using the OpenSearch API."

Adamski
There is no Cygwin to start. If you mean the cygwin batch file, that just runs bash.
anon
@Neil: Yes I meant running bash in order to launch Nutch.
Adamski
... although having seen Havenard's answer I guess I meant "Rather than using Java to start another executable."
Adamski
A: 

You can use any Cygwin program without passing thru Cygwin, just like any regular Windows Console Application. Take a look at the Cygwin\bin\ dir. You may even bring the programs you want to your app dir, sinse you bring a copy of the CYGWIN1.DLL with them.

Havenard
Please note that the Cygwin DLL is GPL licensed. If you want to use Cygwin features in your own code, either your code must also be GPL, or you need to buy a non-GPL license from Red Hat.
anon
A: 

A more interesting, more clever thing to do, would be starting Nutch from Cygwin or using a real Linux/Unix system.

+1  A: 

First of all you have to set the bash.exe to environment variable so this line will start bash.

Runtime rt= Runtime().getRuntime().execute("bash");
Bindas
A: 

If you are trying to run a binary that requires the cygwin1.dll (which includes most commands you can execute from the cygwin bash shell) then you can run it by specifying the cygwin\bin directory in the path environment variable like this:

Process p = Runtime.getRuntime().exec(
      "C:/path/to/cygwin/binary.exe", new String[] { "PATH=C:\\cygwin\\bin" });

This assumes you installed cygwin in C:\cygwin

Anonymous