H
hyena
Sorry for asking again, but till now I haven't solved it.
Just got a weird problem in JNI. I made a DLL in BCB and call it in Java,
the dll
shows one float value using a messagebox.
The problem is: when I call the DLL in java, it gives me a value in the
msgBox, and keep rerurning the same one which is supposed to change time by
time. whilst it gives me another value if I use debug mode in BCB and works
fine. I tried use another C++ exe to call this dll, everything works fine.
for example,if I run this in in BCB(setting the parameters using javaw with
classpath etc.), I got a value showed as, say, 47.2. And I got a value of
maybe 52.4 if I run this from java part and if I call more then one time in
Java, it sticks to the value and never change. Anyone has come across this
problem?
In java side, I have a class:
public class MyDLL {
public native static void displayValue();
static {
System.load("D:\\Mywork\\mydll.dll");
}
...
public static void main(String[] args) {
displayValue();
}
...
}
and in C++ side,
in MyDLL.cpp which compiled into myDLL, The function is defined as:
JNIEXPORT void JNICALL Java_scheduler_DLLScheduler_displayHelloWorld
(JNIEnv *env, jclass clas)
{
TSys* myS = new TSys();
exTPe* myTPe;
initialize(myS); //read the parameter files
myS->Execute();
myTPe = (exTPe*)(myS->Pe[0]);
rt = myTPe->showValue(); //here a msgBox shows the value calculated in
myTPe class
delete myS;
return ;
}
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}
the defination of showValue(),
double exTPe::showValue(){
this->CalcdU();
this->CalcU();
.....
sprintf(s,"Value is %4.3f",U);
Application->MessageBoxA(s,"value",MB_OK);
}
I hope this somehow explains the problem, and hope somebody has experienced
this error before
Just got a weird problem in JNI. I made a DLL in BCB and call it in Java,
the dll
shows one float value using a messagebox.
The problem is: when I call the DLL in java, it gives me a value in the
msgBox, and keep rerurning the same one which is supposed to change time by
time. whilst it gives me another value if I use debug mode in BCB and works
fine. I tried use another C++ exe to call this dll, everything works fine.
for example,if I run this in in BCB(setting the parameters using javaw with
classpath etc.), I got a value showed as, say, 47.2. And I got a value of
maybe 52.4 if I run this from java part and if I call more then one time in
Java, it sticks to the value and never change. Anyone has come across this
problem?
In java side, I have a class:
public class MyDLL {
public native static void displayValue();
static {
System.load("D:\\Mywork\\mydll.dll");
}
...
public static void main(String[] args) {
displayValue();
}
...
}
and in C++ side,
in MyDLL.cpp which compiled into myDLL, The function is defined as:
JNIEXPORT void JNICALL Java_scheduler_DLLScheduler_displayHelloWorld
(JNIEnv *env, jclass clas)
{
TSys* myS = new TSys();
exTPe* myTPe;
initialize(myS); //read the parameter files
myS->Execute();
myTPe = (exTPe*)(myS->Pe[0]);
rt = myTPe->showValue(); //here a msgBox shows the value calculated in
myTPe class
delete myS;
return ;
}
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}
the defination of showValue(),
double exTPe::showValue(){
this->CalcdU();
this->CalcU();
.....
sprintf(s,"Value is %4.3f",U);
Application->MessageBoxA(s,"value",MB_OK);
}
I hope this somehow explains the problem, and hope somebody has experienced
this error before