java-native-interface
Linking using g++ fails searching for -lstdc++
Posting for future reference, a solution I found was to install g++-multilib. I had the same incompatible problem relating to -lstdc++ on g++ version 4.6.1 On further probing: g++-multilib is a dummy package which installed g++4.6-multilib which in turn installed the appropriate libstdc++.so under the /usr/lib/gcc/x86_64-linux-gnu/4.6/32 folder.
Weird Native Crash – pid: 0, tid: 0 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
Weird Native Crash – pid: 0, tid: 0 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
Looking for a convenient way to call Java from C++
Yes, there are existing tools that do exactly this — generate C++ wrappers for Java classes. This makes use of Java APIs in C++ more transparent and enjoyable, with lower cost and risk. The one that I’ve used the most is JunC++ion. It’s mature, powerful and stable. The primary author is very nice, and very … Read more
JNI – Passing large amounts of data between Java and Native code
What would be the most efficient way to pass the bytes from Java to my native code? I have access to it as a byte array. I don’t see any particular advantage to passing it as a byte buffer (wrapping this byte array) vs a byte array here. The big advantage of a direct ByteBuffer … Read more
jni.h: no such file or directory
You have to add the JDK path to the include path, so the compiler knows the location of the file. Windows: /I “$(JAVA_HOME)\include” /I “$(JAVA_HOME)\include\win32″ Linux: -I”${JAVA_HOME}/include” -I”${JAVA_HOME}/include/linux” Mac: -I”${JAVA_HOME}/include” -I”${JAVA_HOME}/include/darwin”
Getting active window information in Java
Save yourself some pain and use JNA. You will need to download jna.jar and jna-platform.jar for the Win32 API. The pinvoke wiki and MSDN are useful for finding the right system calls. Anyway, here is the code to print the title and process of the currently active window. import static enumeration.EnumerateWindows.Kernel32.*; import static enumeration.EnumerateWindows.Psapi.*; import … Read more