/*--------------------------------------------------------------------------*/ BOOL ExecuteInitialHooks(void) { JNIEnv * currentENV = getScilabJNIEnv(); JavaVM * currentJVM = getScilabJavaVM(); jint result = (*currentJVM)->AttachCurrentThread(currentJVM, (void **) ¤tENV, NULL) ; if (result == 0) { jclass cls = NULL; cls = (*currentENV)->FindClass(currentENV, "org/scilab/modules/core/Scilab"); catchIfJavaException(_("Could not access to the Main Scilab Class:\n")); if (cls) { jmethodID mid = NULL; mid = (*currentENV)->GetStaticMethodID(currentENV, cls, "executeInitialHooks", "()V"); if (mid) { (*currentENV)->CallStaticVoidMethod(currentENV, cls, mid); } catchIfJavaException(_("Cannot execute initial hooks. Error:\n")); return TRUE; } } return FALSE; }
/*--------------------------------------------------------------------------*/ char * system_setproperty(char *property,char *value) { char *retValue = NULL; JNIEnv * currentENV = getScilabJNIEnv(); if (currentENV) { jclass cls = NULL; cls = (*currentENV)->FindClass(currentENV, "java/lang/System"); if (cls) { jmethodID mid = NULL; mid = (*currentENV)->GetStaticMethodID(currentENV, cls, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); if (mid) { BOOL bOK = FALSE; const char *strPreviousValue = NULL; jstring jstrProperty; jstring jstrValue; jstring jstrPreviousValue; jstrProperty = (*currentENV)->NewStringUTF(currentENV,property); jstrValue = (*currentENV)->NewStringUTF(currentENV,value); jstrPreviousValue = (*currentENV)->CallStaticObjectMethod(currentENV,cls, mid,jstrProperty,jstrValue); bOK = catchIfJavaException(""); if (bOK) { if (jstrPreviousValue) { strPreviousValue = (*currentENV)->GetStringUTFChars(currentENV,jstrPreviousValue, 0); if (strPreviousValue) { retValue = strdup(strPreviousValue); } (*currentENV)->ReleaseStringUTFChars(currentENV, jstrPreviousValue , strPreviousValue); } } } } } return retValue; }