Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

i have to call c# file/program from java program how to do it ?  RSS feed

 
kulbhushan patil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me how to run c# file through java program
 
Smitesh Shinde
Ranch Hand
Posts: 45
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22833
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15860
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 53747
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!