Pass an ArrayList of objects from C++ to JAVA using JNI

Hello,

I need to get the running Windows processes using C++ and have a Process struct in C++ having 2 fields: name and pid. I want to pass an ArrayList of Process from C++ to Java. I have found an example of how to pass an array of objects from C++ to Java, but I'd like to pass an ArrayList, and I was wondering if this is possible, before understanding that example and use an array.

I don't have much experience with C++ and I don't even know if you have something like an ArrayList in C++, so I'm sorry if it doesn't make any sense what I'm talking about. Thank you.

[596 byte] By [z23a] at [2007-11-26 22:03:30]
# 1
From C you can access and/or imnstantiate one of the java collections. In other words, your C code should simply populate java structures and a collection.
bschauwejavaa at 2007-7-10 10:45:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

> From C you can access and/or imnstantiate one of the

> java collections. In other words, your C code should

> simply populate java structures and a collection.

I have read this is possible after I posted this, but didn't find an example yet. I began reading "Java Native Interface" book from Addison-Wesley today to get a better understanding of JNI.

If you know where to find an example of doing this, I would appreciate it. Otherwise, I suppose I will find this in the above mentioned book quite soon... Thank you.

z23a at 2007-7-10 10:45:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Afraid I don't have an example at hand. However what you want is commonly referred to as the "invocation api". It bascially allows you to call into java from C.
bschauwejavaa at 2007-7-10 10:45:30 > top of Java-index,Java HotSpot Virtual Machine,Specifications...