3 ms·
Didn’t JNI allow that kind of integration?
by sedatk 6y ago
Didn’t JNI allow that kind of integration?
- DaiPlusPlus 6y agoI think it was because MS’ Java’s standard libraries included Java wrappers over Win32 already, so programming beginners in Java can make “real”-looking Windows desktop GUI applications without knowing any C or at least knowing how to read *.h files and translate them to Java.
- josefx 6y agoMicrosoft had RNI which was comparable to JNI and could be used to write native code. It also had J/Direct which could be used to bind existing native code to a Java method declared native with only a comment, the closest to that for standard Java that I know of is JNA and apparently that wasn't around until 2007?
- int_19h 6y agoJNI is a bit different - you have to write code in C or C++ that wraps native APIs you want to call, in a certain very specific way that then makes it possible to call it via methods declared as "native" in Java. P/Invoke does not require such a layer - you simply declare enums, structs, and functions from the native API directly in your C# code, and then you can call them. For those familiar with Python, the Java way is more like writing a Python extension module in C, and the C# way is more like using ctypes (but way faster). Java has some third party libraries that are basically P/Invoke equivalent; JNA is probably the most used one.