5

I have been given a task to create a bridge between C# and Java. It was said that if we use C# right now, and then we receive a Java file from somewhere else, we should be able to convert that Java file into .NET so it can be compatible with our software. The problem is I don't know what to do or how to even begin this task. Any suggestions or advice?

It was said that I initially have to make platform independent classes, if that helps.

*Edit: Sorry if I wasn't clear the first time, because I don't fully understand the task myself, which is why I am here. But from what I understand, I do have to create the bridge itself where I can call the source Java code from my .NET file. I have several months to finish it, so I assume that I have to make every library in Java compatible with C#.

I looked around for help, and found some similar projects: JNBridge(pay to use), Tangible(free demo), and Janett(open source), so that is what I am basing my opinion from.

**Edit: Let's say for example I create a Calculator class in Java. I would want to create the instance of that class in C#.

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Alexey
  • 3,607
  • 8
  • 34
  • 54
  • 5
    what do you mean by Java file? Java source code (or) data sent by system which was developed in Java (or) some other language? – kosa Jan 17 '12 at 21:29
  • Are you wanting to (1) communicate with existing Java-compiled code from C# (like a "bridge"), or (2) port Java code to C# ("convert that Java file into .NET")? Your question isn't at all clear in this respect. And these are completely different things/tasks. – James Johnston Jan 17 '12 at 21:30
  • this is a pretty daunting task...assuming you mean source code, is this even feasible? c# and java have pretty strong similarities but certain constructs dont even exist in java that do in c# and vise versa. for example linq, delegates, dynamic types, anonymous objects, etc.. – Nadir Muzaffar Jan 17 '12 at 21:31
  • You can convert Java binaries to .NET See http://www.ikvm.net/ – L.B Jan 17 '12 at 21:32
  • You can try the [JLCA](http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=14349) although i've never used it and doubt that it'll work in any later than VS 2005. Here are more infos: http://msdn.microsoft.com/en-us/magazine/cc163422.aspx – Tim Schmelter Jan 17 '12 at 21:36
  • @TimSchmelter, JLCA is for VS2003 and no newer version is available. – L.B Jan 17 '12 at 21:40
  • @L.B: But according to my second link above: "the JLCA is included with Visual Studio 2005 " – Tim Schmelter Jan 17 '12 at 21:42
  • @TimSchmelter OK, I was wrong, It is 2 years younger. But that's all. I used it and wouldn't recommend for anyone. – L.B Jan 17 '12 at 21:45
  • Question as stated is ridiculously. You receive a java file from where? What kind of file, a .java that needs to be converted to a .cs file (hard to do good), a .jar file that needs to be decompiled and recompiled as a .NET binary (did I mentioned impossible?)? And do you want it to be executed afterwards? And why do you want to do all of this?I really can't believe the upvoter. – CodeCaster Jan 17 '12 at 21:48
  • 2
    @CodeCaster, Please try IKVM. I used it to convert Lucene, Jericho Html Parser, Mobile Atlas Creator etc binaries to .Net and used in many projects. It is not a joke, it is real. I really can't believe this ignorance. – L.B Jan 17 '12 at 22:07
  • @CodeCaster, you can even host java classes (without prior conversion) in .Net :) I really want to see who voted for close. – L.B Jan 17 '12 at 22:17
  • @L.B the techniques can exist, which I do not question, but the question itself is too vague. – CodeCaster Jan 18 '12 at 08:17

3 Answers3

5

I have never used this, IKVM.NET may be worth checking out.

IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. It includes the following components:

- A Java Virtual Machine implemented in .NET
- A .NET implementation of the Java class libraries
- Tools that enable Java and .NET interoperability

The one time I've seen it was a while ago, when working with a proprietary .NET based CMS. That assembly was used, but I'm not sure in what capacity.

wsanville
  • 37,158
  • 8
  • 76
  • 101
  • 1
    I don't know how I missed IKVM, but I think I need to make something which resembles it, because it convert Java libraries to .NET. – Alexey Jan 18 '12 at 15:34
0

Depending on the situation, there are a large number of integration technologies that can be used to bridge two systems. In fact, there is an entire software architecture paradigm devoted to this called a Service Oriented Architecture. Any of the techniques used for inter-service communication can be used to integrate any two systems, no matter the size. There are tradeoffs, of course, but there always are.

Without much more information regarding the systems involved and the level of integration needed, it is going to be very hard for a definitive answer to be found for this question.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173
0

From your explanation of what you want your bridge to do, it sounds like JNBridge could well solve your problem and save a lot of time reinventing the wheel. If you have any questions, please contact us at JNBridge -- there's a contact link on the website. (Disclosure: Yes, I work for JNBridge.)

Wayne Citrin
  • 133
  • 7