Java and C# together

I’m writing this post to give people an answer to a problem that I had: embedding a C# control inside of a Java application. After searching for answers, I finally came upon the perfect combination.

1. Create an ActiveX control with the C# application using this:

http://code.msdn.microsoft.com/windowsdesktop/CSActiveX-b86194f8. Just start by downloading the whole project and modifying it from there.  Change the name of the control, change the guids, etc.  Also, make sure that you modify the Release version to register for COM Interoperability as that’s not set by default in the project.

2. Embed the control in your Java application using this:

http://www.eclipse.org/articles/article.php?file=Article-ActivexSupportInSwt/index.html

and this:

www.eclipse.com/swt

The Standard Widget Toolkit lets you embed ActiveX controls in your Java applications.  You can then communicate with them directly using the Dispatch interface for the control without needing to create a JNI interface yourself or using another toolkit.

I have found this method both reliable and straightforward.  Good luck.

Just so people can have a chance at finding this article, I’m going to put a few phrases people might search for here at the bottom.

Embedding C# in Java. C# controls in Java. Creating a C# ActiveX control. Embedding ActiveX controls in Java. Putting C# and Java together.