Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

Good Afternoon.

I have an Application Containing Two methods
The application is Coded in Java.

How Can I call Java methods from VS C#.net.

can anyone Help me?

Thanks and Regards
Lakshman C B
Posted
Comments
Pravin Patil, Mumbai 5-Oct-11 6:08am    
What type of application is it that you mentioned is in JAVA..? i.e. is it API, Console application or what..?
Lakshmancb 5-Oct-11 7:14am    
Hello Mr. Pravin,

Its a simple applcation in Java containing two methods.
Those Tow methods should be accessible from outside.

Thanks
Lakshman

From a quick Google (which you should have tried first), these guys[^] offer a paid-for solution, though I don't know how much it is.

There is no simple way, as the two VMs are completely incompatible. You need to write communication/marshalling code on both sides, or use a tool which writes it for you (for example web services).

If you are in control of the source code on both sides it may be best to rewrite the Java part in a .Net language, if .Net is your target final platform. That depends on how deeply integrated the code is with Java libraries etc that there is no direct equivalent for in the Framework.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 16:03pm    
Yes, I heard about this, my 5 for bringing this link.
However, there are three well-known free products here, two of them open-source; please see my solution.
--SA
Simon Bang Terkildsen 6-Oct-11 8:02am    
+5
You could do one thing: move Java code to .NET using some product implementing Java as language for .NET and Mono.

One such product is IKVM.NET, http://en.wikipedia.org/wiki/J_Sharp[^]. The product is free, under permissive zlib License, http://en.wikipedia.org/wiki/Zlib_License[^].

Another option like this is J#, but this project is not supported now, see http://en.wikipedia.org/wiki/J_Sharp[^], http://msdn.microsoft.com/en-us/vjsharp/default.aspx[^].

The last choice from this row is Ja.NET, see http://www.janetdev.org/[^], also Open Source.

I would look at IKVM.NET first.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 5-Oct-11 16:38pm    
IKVM is pretty nice
Sergey Alexandrovich Kryukov 5-Oct-11 16:55pm    
Thank you, Espen.
Did you use it?
--SA
Espen Harlinn 5-Oct-11 17:04pm    
Yes, it's any easy way to move stuff from java to .Net.
About a year ago I wrote a JNI based Jave/.Net integration layer based on ideas from Jace. I thought about a name "Jni4Net" and discovered that Jni4Net already was used for a similar piece of technology - I took it for a spin, and threw out my own code :-/ - well these things are bound to happen from time to time :-D
Sergey Alexandrovich Kryukov 5-Oct-11 17:23pm    
Great.
I understand this way is easy enough. :-)
--SA
Simon Bang Terkildsen 6-Oct-11 8:04am    
My 5
Have a look at Jni4Net[^] - it's free and works fairly well - actually it's pretty powerful :)

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Simon Bang Terkildsen 6-Oct-11 8:04am    
nice one, got my 5
Espen Harlinn 6-Oct-11 10:25am    
Thank you, Simon!
Write a Java webservice wrapper which will call these two methods and host the service.

Now call this webservices in your .NET application and you are done.
 
Share this answer
 
If you have Java source code, you should rewrite those methods in C#.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900