| Author |
i have to call c# file/program from java program how to do it ?
|
kulbhushan patil
Greenhorn
Joined: Aug 10, 2010
Posts: 6
|
|
|
please tell me how to run c# file through java program
|
 |
Smitesh Shinde
Ranch Hand
Joined: Feb 16, 2008
Posts: 44
|
|
As far as I know C# produces exe file after the compilation. You can exeute the .exe files from a java program as if it is executed from commandline. Do research on how to exeute commands in java.
If you are looking for calling particular method in your C# from java then I believe web services is the only way.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Agreed. To start C# program, just exec() it. A C# program is just another executable.
To communicate with an already running program, web-services is an option, but so are files, network sockets, and any form of IPC.
And finally, to call a function that was written in C# (or any .NET library function) from Java, you can use JNI. However, all JNI will do is get you to C/C++, or in Microsoft speak, to Unmanaged C++ -- you will need to write a simple Managed C++ object that can forward request from the unmanaged side to the .NET library.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
|
In the project I'm currently working on, we use a library for this: JuggerNET. It isn't always easy to use, though - especially because of the conversion of Java objects to C# objects and vice versa.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
We all know, of course, that you never go near exec() until you have read the classic article by Michael Daconta, "When runtime.exec() won't".
And I think this is too difficult for "beginning", so shall move the thread.
|
 |
 |
|
|
subject: i have to call c# file/program from java program how to do it ?
|
|
|