Does JNI work properly when calling multi-threaded C++ code? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm trying to decide if JNI is for our use case.
We have a library written in C++ that fetches data from Database/RPC using multiple threads, and we want to create a wrapper to let Java code be able to call it.
I'm not familiar with JNI, so I would like to know if C++ multithreading will still work properly in this case.
Thanks.

I don't see any major issues in neither direction. Unless you have something really specific.
Here you have sample that calls JNI code from multiple threads:
http://jnicookbook.owsiak.org/recipe-No-024/
Here you have sample that calls Java from multiple C threads:
http://jnicookbook.owsiak.org/recipe-no-027/

Related

Call a already generated C code from java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is it possible to call the C code (which has been generated py Beremiz Editor) from java?
I dont want to edit the generated C code i just want to call it from my Java program.
Instead of modifying the generated code, you can write a bridge in C that would accept calls from Java and forward them to your generated code. It can be compiled together with the generated code, making the single .dll or .so library.
JNI interface has many specific requirements and agreements. It cannot be used to call the arbitrary C function that was written without having JNI in mind.
This is a very common task when integrating existing C libraries into Java framework.
You can use JNI to do this, a good tutorial is available here:
https://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html
This allows you to call your C code from in java.

What is the most efficient(fastest) way of passing data from C++ to Java? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What is the most efficient way of passing data from C++ to Java?
The Java application will need to call the C++ application to retrieve the data.
I can see the following ways of achieving this:
Using JNI
Using a file based approach
Using SWIG
My current thinking is to use JNI. AM I missing a better method before I commit?
Java Native Interface allows you to pass anything back and forth between C++ and Java. It supports both directions, but can be tricky. There are others you can look at Swig is one and then you have JNA. I would go with JNI
JNI would be the best approach. Notice that javah creates compatible header-files for your java-class, its very tricky to to write compatible header-files by your own, so please use javah.

How to do explicit multithreading in MATLAB using JAVA? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I just want to know how to do multithreading using java in MATLAB? I know there is parallel computing toolbox in MATLAB by this one can implement parallel computing and in JAVA by extending Thread Class we can do multithreading.
I want to execute multithreading using java code in MATLAB without using PCT of MATLAB? Please provide a code if possible.. I studied several literature but still can't be able to execute even a single program of java using MATLAB.. Thanks in Advance!!!
You could try reading through the example from this article on the Undocumented MATLAB blog, which illustrates calling threaded Java from MATLAB. It's one of a four-part series discussing several other ways of implementing threads, including .NET and MEX.

Porting an app from Java to Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have written an RTMPS client a while back and needed it for my Django application but since Java and Python don't play well without using system calls (I don't want to use Jython) I wanted to rewrite the application in Python.
Would it work if I ported it as if to Python from Java? Of course we have to take into account the obvious things like multiple constructors have to be done differently in Python. Are there any other things that would not make it work in Python?
I am doing this because Java is so memory heavy and hoping that moving in into Python would reduce memory footprint and thus allow my web app to use it.
I would suggest rewriting it completely but there are a lot of differences to take into account. Here's a starter for recognizing some of the common differences/mistakes: http://dirtsimple.org/2004/12/python-is-not-java.html
Also if you are too lazy to rewrite the code (like me) there is an other option: java2python

program in java to get info about Ram [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want a program to get information about RAM
How can i do that?
There's a couple of memory-related methods in the Runtime class, but note that they only give information about the amount of memory available to (or used by) the JVM, not the hardware it runs on.
Generally, Java is the wrong language to do this kind of thing, since it requires access to OS APIs that Java does not provide.
Most of the information you need will be contained in the Runtime class. Have a look at the link. It should be straightforward. If you run into problems with it, I will try to help you out further.

Categories