W
wignas
Hi all, I have a question and would really appreciate any help with
this. (Sorry for double posting but not sure in which group I should
post this)
So, I have connected a Java class and a Visual Studio C++ Dll-project
using JNI, here is the C++ code:
#include <windows.h>
#include <string.h>
#include "prog1.h" //The machine generated header file
#include "Logic.h" //I want to use the methods in this header
BOOL WINAPI DllMain(HANDLE hHandle, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}
JNIEXPORT jint JNICALL Java_prog1_Sum(JNIEnv *, jclass, jint a, jint b)
{
//TestJava(); //This wont work
return a + b;
}
JNIEXPORT jstring JNICALL Java_prog1_saySomething(JNIEnv * env, jclass,
jstring strString)
{
char *lpBuff = (char*)env->GetStringUTFChars(strString, 0);
_strupr(lpBuff);
jstring jstr = env->NewStringUTF(lpBuff);
env->ReleaseStringUTFChars(strString, lpBuff);
return jstr;
}
I have tested to use this JNI-methods from Java and it works fine, but
now I want call my old C/C++ methods in "Logic.h" from this JNI
interface. How do I do that? Say I have a simple method in Logic.c like
this:
extern void TestJava()
{
CAN_DATA_WriteConvX myConv1Settings;
myConv1Settings.Motor0 = MotorOn;
outputConv1(myConv1Settings);
}
I can't call this from my JNIEXPORT methods, but I can call it from any
other "ordinary" cpp method. So how should I do for using the old
methods in Logic.h from Java?
Thanks for any help. /Jonas
this. (Sorry for double posting but not sure in which group I should
post this)
So, I have connected a Java class and a Visual Studio C++ Dll-project
using JNI, here is the C++ code:
#include <windows.h>
#include <string.h>
#include "prog1.h" //The machine generated header file
#include "Logic.h" //I want to use the methods in this header
BOOL WINAPI DllMain(HANDLE hHandle, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}
JNIEXPORT jint JNICALL Java_prog1_Sum(JNIEnv *, jclass, jint a, jint b)
{
//TestJava(); //This wont work
return a + b;
}
JNIEXPORT jstring JNICALL Java_prog1_saySomething(JNIEnv * env, jclass,
jstring strString)
{
char *lpBuff = (char*)env->GetStringUTFChars(strString, 0);
_strupr(lpBuff);
jstring jstr = env->NewStringUTF(lpBuff);
env->ReleaseStringUTFChars(strString, lpBuff);
return jstr;
}
I have tested to use this JNI-methods from Java and it works fine, but
now I want call my old C/C++ methods in "Logic.h" from this JNI
interface. How do I do that? Say I have a simple method in Logic.c like
this:
extern void TestJava()
{
CAN_DATA_WriteConvX myConv1Settings;
myConv1Settings.Motor0 = MotorOn;
outputConv1(myConv1Settings);
}
I can't call this from my JNIEXPORT methods, but I can call it from any
other "ordinary" cpp method. So how should I do for using the old
methods in Logic.h from Java?
Thanks for any help. /Jonas