Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I start a .NET application from Java on Linux, Mac and Windows?

I want to start a .NET application (compatible with Mono) from the context of a Java environment.

My guess would be that I'd have to somehow figure out if mono is installed, find the location and start that using the .NET application path as a parameter.

But what is a robust way to do it? Or is there a better way?

Perhaps I should clarify the context: the Java part is running as a plugin in an environment with limited interaction possible, so I would really prefer to find a way without having to need a configuration file or an user-interface.

like image 450
Davy Landman Avatar asked Nov 15 '22 04:11

Davy Landman


1 Answers

If you already have .net/mono already installed and you can double click on the exe file and it runs, then you could just use Desktop.open()

As easy as:

Desktop.getDesktop().open(file);

See here for more details: Using the Desktop API in Java SE 6 EDIT

I had to boot my Linux box where I have a mono application and this worked just great:

class Launch { 
   public static void main( String ... arg ) { 
      new ProcessBuilder("/usr/bin/myapp").start();
   }
}

Repeat, worked just great!

like image 65
OscarRyz Avatar answered Nov 16 '22 16:11

OscarRyz