• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please tell me how to run c# file through java program
 
Ranch Hand
Posts: 45
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic