1

I need to call a Java API (JAR file) in a C# application. Is it possible to call a Java API without using any tool like IKVM?

I don't want to be depending on any tool.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
crm dev
  • 11
  • 1
  • Possible duplicate of [How to run jar file form C# code](https://stackoverflow.com/questions/23753060/how-to-run-jar-file-form-c-sharp-code) – mybirthname Jul 07 '17 at 11:26
  • Does not seem like a duplicate, this question seems to ask how to use an API, not simply execute a jar code. Some clarification might be required. – NaeiKinDus Jul 07 '17 at 11:33
  • Sorry, it's not a duplicate as I am aksing about any way to call jar files in c# not how to run it. – crm dev Jul 07 '17 at 11:34
  • NaeiKinDus , could you tell me which type of clarification should I add ? – crm dev Jul 07 '17 at 11:35
  • Why do you don't want to use existing and working solutions? Don't reinvent the wheel... – Mischa Jul 07 '17 at 11:37
  • https://stackoverflow.com/questions/512124/use-a-jar-java-library-api-in-c – StefanE Jul 07 '17 at 11:37
  • Mischa Behrend My Cient has sent me an api java to use so I need to call it in my c# code – crm dev Jul 07 '17 at 11:41
  • StefanE, the answer of the post you give is to use ikvm but as I said in my question I shoudln't use any other tool. – crm dev Jul 07 '17 at 11:42
  • Why? **Why** do you not want to use IKVM? – Mischa Jul 07 '17 at 11:44
  • I will depend on this tool and my client doesn't accept that I depend any other tool so I need wheter to tell him that it's possible wheter it's not but without using any other tool. – crm dev Jul 07 '17 at 11:48
  • reading [this](https://stackoverflow.com/a/512247/4273199) answer, there are two options to use IKVM. First: use a tool from them to "convert" your `.jar`into a `.dll` and reference that in your C# project. (Work is done without thirdparty software, **in execution**) | Second: Use their tool to reference the `.jar` directly... (not what you want) – Mischa Jul 07 '17 at 11:53
  • do you know why your client doesn't want third party tools? – Mischa Jul 07 '17 at 11:55
  • I think he doesn't want to depend on any tool that's why I have to respect his decision. 1- For converting .jar to .dll I have 3 files .jar and I was not able to convert 2 of them to .dll but only to .exe So I don't know if the solution ikvm for converting will help me ?. 2- do you know any way just by using some lines of c# codes for using jar files? – crm dev Jul 07 '17 at 12:04
  • 1 - That probably while these .jar files have a `Main()`-Method defined... which makes them executables... – Mischa Jul 07 '17 at 12:10
  • 2 - No, I do not know a easy way to do this... Addition to 1 - You can reference `.exe` files the same way as `.dll` files – Mischa Jul 07 '17 at 12:17

0 Answers0