Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java and C# interoperability

Tags:

java

c#

interop

People also ask

What is difference C and Java?

C is a compiled language that is it converts the code into machine language so that it could be understood by the machine or system. Java is an Interpreted language that is in Java, the code is first transformed into bytecode and that bytecode is then executed by the JVM (Java Virtual Machine).

Which is better C or Java?

C is a procedural, low level, and compiled language. Java is an object-oriented, high level, and interpreted language. Java uses objects, while C uses functions. Java is easier to learn and use because it's high level, while C can do more and perform faster because it's closer to machine code.

Is Java based on C?

The syntax of Java is largely influenced by C++ and C. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language.

Can you use Java and C together?

If you want to call native code from Java program, you should use JNI. This will require preparation in the C side of your code, but it works pretty good. If you are new to programming, again, I would recommend avoiding that. Regarding GUI - you can work with Swing.


I am author of jni4net, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.


Kyle has the right approach in asking about the interaction. There is no "correct" answer without knowing what the usage patterns are likely to be.

Any architectural decision -- especially at this level -- is a trade-off.

You must ask yourself:

  • What kind of messages need to be passed between the systems?
  • What types of data need to be shared?
  • Is there an important requirement to support complex model objects or will primitives + arrays do?
  • what is the volume of the data?
  • How frequently will the interactions occur?
  • What is the acceptable communication latency?

Until you have an understanding of the answers, or potential answers, to those questions, it will be difficult to choose an implementation architecture. Once we know which factors are important, it will be far easier to choose the more suitable implementation candidates that reflect the requirements of the running system.


I've heard good things about IKVM, the JVM that's made with .NET.


Ice from ZeroC is a really high performance "enterprisey" interop layer that supports Java and .net amongst others. I think of it as an updated Corba - it even has its own object oriented interface definition language called Slice (like Corba's IDL, but actually quite readable).

The feature set is extensive, with far more on offer than web services, but clearly it isn't an open standard, so not a decision to make lightly. The generated code it spits out is somewhat ugly too...