I am trying to start a Windows Forms application from Java (eclipse rcp plugin) using the following code.
// locate resource in plugin
Bundle bundle = Platform.getBundle("com.acme.devicewebservice");
URL url = FileLocator.find(bundle, new Path("dotnet"), null);
url = FileLocator.resolve(url);
File f = new File(url.toURI());
if(f.isDirectory())
{
// start app
File prg = new File(f, "MyApp.exe");
ProcessBuilder pb = new ProcessBuilder(prg.getAbsolutePath(), "-port", "8081");
pb.directory(f);
pb.environment().put("PATH", f.getAbsolutePath());
process = pb.start();
}
The process starts but the application does not appear.
If I start notepad.exe
then the Notepad appears.
ProcessBuilder pb = new ProcessBuilder("notepad.exe");
If I start the application using cmd
that works to but I never get the Process
object of my app.
ProcessBuilder pb = new ProcessBuilder("cmd", "/C", "start", prg.getAbsolutePath());
Is this a problem with Java or with the Windows application? I have the sources for both.
Update The above app is an eclipse rich client. I tried starting the process from a simple Java app and this works. I then tried starting it from a simple SWT app and this works too. Now wondering what is different with a rich client app...