Hello,
I've now looked into how to use java 1.6 and with the help of the answer to the issue I posted quite some time ago, now managed to turn off floating point instructions.
Would appreciate if you can tell me how to also overcome the problem to feed the java code with one or more parameter(s).
LoadLib has been tested to dynamically load and use the dll for SQLite3 and Cairo, both the OW and GCC builds (the gcc builds installed with current ANPM) without recompile in between. The example code I used with SQLite3 and Cairo loaded with parameter "false" as they don't need the floating point fix. :-)
Try with OW as you like, but don't blame me if you run into problems.
Ohh, anyone that would like to help me to write code in vxrexx for this?
A gui to use java in the background etc.
#define INCL_DOS
#define INCL_DOSMODULEMGR
#define INCL_DOSMISC
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
#include <ctype.h>
#include <jni.h>
#include <stdlib.h>
#include <iostream>
#include "LoadLib.hpp"
LoadLib *javm;
ULONG rc;
JNIEnv* create_vm() {
javm = new LoadLib( "client\\jvm" );//, ".", false ); //when used with sqlite3 and cairo
if( javm->rc == NO_ERROR ) {
JavaVM* jvm;
JNIEnv* env;
JavaVMOption options[] = {
{ "-Xmx512m", NULL },
{ "-XX:+TraceClassLoading", NULL },//To see the origin of the problem class
{ "-Djava.class.path=.", NULL }, //D:\\Programs\\vxrexx\\projects\\ODBCADMN\\j4o";
{ "-Djava.library.path=.", NULL },// set native library path
{ "-Djava.compiler=NONE", NULL }, // disable JIT
{ "-verbose:gc", NULL }, // print gc messages
{ "-verbose:jni", NULL }, // print JNI-related messages
{ "-verbose:class", NULL } // print class loading messages
};
JavaVMInitArgs args;
args.version = JNI_VERSION_1_6;
args.nOptions = sizeof( options ) / sizeof( JavaVMOption );
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
InitFunc( javm->hmod, jint, JNI_CreateJavaVM, ( JavaVM **p_vm, void **p_env, void *vm_args ) );
jint jrc = JNI_CreateJavaVM( &jvm, (void**)&env, &args );
//#ifdef __WATCOMC__
if( jrc != JNI_OK )
cerr << "Problems loading JVM" << endl;
else
cout << "JVM has been loaded sucessfully" << endl;
//#endif
delete options;
return env;
}
return NULL;
}
void invoke_class( JNIEnv* env ) {
cout << "invoke class" << endl;
jclass helloWorldClass;
jmethodID mainMethod;
jobjectArray applicationArgs;
jstring applicationArg0;
cout << "FindClass HelloWorld" << endl;
helloWorldClass = env->FindClass( "HelloWorld" );
cout << "main helloWorld" << endl;
mainMethod = env->GetStaticMethodID( helloWorldClass, "main", "([Ljava/lang/String;)V" );
cout << "New Args" << endl;
applicationArgs = env->NewObjectArray( 1, env->FindClass( "java/lang/String" ), NULL );
cout << "New UTF String to test parameters" << endl;
applicationArg0 = env->NewStringUTF( "testparam" );
cout << "Args" << endl;
env->SetObjectArrayElement( applicationArgs, 0, applicationArg0 ); //KABOOM! Unless commented out. :-(
cout << "void main" << endl;
env->CallStaticVoidMethod( helloWorldClass, mainMethod, applicationArgs);
}
int main( int argc, char **argv ) {
JNIEnv* env = create_vm();
if( env )
invoke_class( env );
else
return 1;
return 0;
}