aspose file tools*
The moose likes Java in General and the fly likes i have to call c# file/program from java program how to do it ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "i have to call c# file/program from java program how to do it ?" Watch "i have to call c# file/program from java program how to do it ?" New topic
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: 45

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: 18989
    
  40

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14346
    
  22

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 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i have to call c# file/program from java program how to do it ?