简体   繁体   中英

integrating java with C#.net

Is following thing possible?if yes how?
I have some core functionality already implemented in Java. Now I want to create a GUI for it. I am finding it difficult to make a GUI in Java using Swing. I can build a GUI easily in C#.net.
So I was thinking if it was possible to create a library in Java that I can access from my C# code.
Shorty: my java code will provide some API and then my C# program must be able to call those APIs.

How do I do this?

Assuming you have properly structured your Java code, creating a Web Service bridge between the two could be the way to go. For example you could expose the Java API through a SOAP and simply make the C# UI depend on that.

The great side in this solution of course is that if you do it this way, you can replace the UI completely at any point you want to, downside is that you would have to run the Java part separately in a context such a servlet container which may be quite heavyweight for your needs.

Depends on what your java library does and if it uses many third party components, but thanks to IKVM you could compile a jar file into a .NET assembly. I've used this approach to incorporate the xhtmlrenderer java library into a C# application with success.

Yes, this is possible.

Have a look at JNBrige: http://www.jnbridge.com/

But, to be honest, I think it would be better to rewrite your APIs in .Net. Makes it easier in the end imho. I prefer working in one environment and not having to maintain things at different places.

have you considered using webservices? You could also execute a java program using something like:

private void calljava(object ob,EventArgs arg)
    {
        Process.Start("j.bat");
    }

There is also JNBridge

Just a few ideas....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM