Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

There is a code sample here that does what you want using JNI to bridge from C++ (Win32 memory mapped files) to Java. Might just work as is, although some cleanup for security and threading might be needed depending on your scenario.

A memory mapped file is still a file. You could read it with java.io, or you could use a MappedByteBuffer from java.nio if you want it memory-mapped in Java too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top