Search code examples
javac++interopmemory-mapped-files

how to access c++ memory mapped files in java


I have a windows c++ application that creates a memory mapped file for a bitmap that is updated frequently. I would like to access to this memory mapped file to display the live image in a java application. How can I do that?

I know that FileChannel can be mapped to memory but I cannot see how to access a memory mapped file created by another process.

I already use JNA in my java application, should I use it to access standard windows memory mapped files functionality?

Or do you have any other solution than the memory mapped file to display a live image stream in java from an image created by a separate program?


Solution

  • I have finaly used jna and the platform library that they provide. The Kernel32 package offers access to the CreateFileMapping and MapViewOfFile functions.