java-native-interface

JNI “undefined reference” to c++ method

耗尽温柔 提交于 2020-05-17 05:48:07
问题 I'm trying to create poker app with JNI in android studio, I want to save one instance of c++ class (TexasHoldem) and invoke it's methods only. in the texasJNI.java I wrote: public class jniTexasHoldem { private long texasHoldm; jniTexasHoldem() { ConstructNativeTexas(); } // Used to load the 'native-lib' library on application startup. static { System.loadLibrary("native-lib"); } /** * A native method that is implemented by the 'native-lib' native library, * which is packaged with this

'Failed to load the JNI shared library “C:\Program Files\Java\jre7\bin\client\jvm.dll” '

a 夏天 提交于 2020-05-15 06:42:25
问题 I have looked for a solution, but all the ones I found didn't work. I have triple checked that I have both 64 bit JRE/JDK and Eclipse I have added the '-vm' argument to the eclipse.ini file. Here's the file content: -startup plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20130807-1835 -product org.eclipse.epp.package.standard.product --launcher.defaultAction openFile --launcher.XXMaxPermSize

Set console title in C++ using a string

ⅰ亾dé卋堺 提交于 2020-05-08 18:13:20
问题 I would like to know how to change the console title in C++ using a string as the new parameter. I know you can use the SetConsoleTitle function of the Win32 API but that does not take a string parameter. I need this because I am doing a Java native interface project with console effects and commands. I am using windows and it only has to be compatible with Windows. 回答1: The SetConsoleTitle function does indeed take a string argument. It's just that the kind of string depends on the use of

Set console title in C++ using a string

时光毁灭记忆、已成空白 提交于 2020-05-08 18:10:26
问题 I would like to know how to change the console title in C++ using a string as the new parameter. I know you can use the SetConsoleTitle function of the Win32 API but that does not take a string parameter. I need this because I am doing a Java native interface project with console effects and commands. I am using windows and it only has to be compatible with Windows. 回答1: The SetConsoleTitle function does indeed take a string argument. It's just that the kind of string depends on the use of

Set console title in C++ using a string

流过昼夜 提交于 2020-05-08 18:10:21
问题 I would like to know how to change the console title in C++ using a string as the new parameter. I know you can use the SetConsoleTitle function of the Win32 API but that does not take a string parameter. I need this because I am doing a Java native interface project with console effects and commands. I am using windows and it only has to be compatible with Windows. 回答1: The SetConsoleTitle function does indeed take a string argument. It's just that the kind of string depends on the use of

Set console title in C++ using a string

半世苍凉 提交于 2020-05-08 18:10:17
问题 I would like to know how to change the console title in C++ using a string as the new parameter. I know you can use the SetConsoleTitle function of the Win32 API but that does not take a string parameter. I need this because I am doing a Java native interface project with console effects and commands. I am using windows and it only has to be compatible with Windows. 回答1: The SetConsoleTitle function does indeed take a string argument. It's just that the kind of string depends on the use of

How to pass a C String Emoji to Java via JNI

痴心易碎 提交于 2020-04-30 11:11:54
问题 I am trying to pass a database value to Java via JNI : __android_log_print(ANDROID_LOG_ERROR, "MyApp", "c_string >>> %s", cStringValue); prints : c_string >>> 👑👟👓 env->SetObjectField(jPosRec, myJniPosRec->_myJavaStringValue, env->NewStringUTF(strdup(cStringValue))); However, this fails without errors. How can you go about passing special characters (such as emojis) to Java in JNI? Thank you all in advance. 回答1: Cribbing from my answer here, you can use the JNI equivalent of Charset.forName(

How to pass a C String Emoji to Java via JNI

非 Y 不嫁゛ 提交于 2020-04-30 11:10:50
问题 I am trying to pass a database value to Java via JNI : __android_log_print(ANDROID_LOG_ERROR, "MyApp", "c_string >>> %s", cStringValue); prints : c_string >>> 👑👟👓 env->SetObjectField(jPosRec, myJniPosRec->_myJavaStringValue, env->NewStringUTF(strdup(cStringValue))); However, this fails without errors. How can you go about passing special characters (such as emojis) to Java in JNI? Thank you all in advance. 回答1: Cribbing from my answer here, you can use the JNI equivalent of Charset.forName(

How to pass a C String Emoji to Java via JNI

左心房为你撑大大i 提交于 2020-04-30 11:10:06
问题 I am trying to pass a database value to Java via JNI : __android_log_print(ANDROID_LOG_ERROR, "MyApp", "c_string >>> %s", cStringValue); prints : c_string >>> 👑👟👓 env->SetObjectField(jPosRec, myJniPosRec->_myJavaStringValue, env->NewStringUTF(strdup(cStringValue))); However, this fails without errors. How can you go about passing special characters (such as emojis) to Java in JNI? Thank you all in advance. 回答1: Cribbing from my answer here, you can use the JNI equivalent of Charset.forName(

why loading JNI in java is done in static initializer?

对着背影说爱祢 提交于 2020-04-14 06:26:06
问题 In many examples of using JNI, I see something like: class SampleClass { static { System.loadLibrary("somelib"); } ... } What is the purpose of this special syntax? why using this (and not just in the class constructor or something like that? 回答1: I think you will get the best answer from the book: Java™ Native Interface: Programmer’s Guide and Specification, The Where you can read: Before the native method print can be called, the native library that implements print must be loaded. In this