I'm making a program that invokes the Java Virtual Machine:
#include <windows.h>
#include <stdio.h>
#include <jni.h>
#define MAIN_CLASS "test"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
JNIEnv* env;
JavaVM* jvm;
JDK1_1InitArgs vmargs;
jint rc;
jclass cls;
jmethodID mainId;
char* szClasspath = getenv("CLASSPATH");
vmargs.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs( &vmargs );
vmargs.classpath = szClasspath;
rc = JNI_CreateJavaVM( &jvm, &env, &vmargs );
if( rc < 0 )
return 1;
cls = (*env)->FindClass( env, MAIN_CLASS );
if( cls == 0 )
return 1;
mainId = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
if( mainId == 0 )
return 1;
(*env)->CallStaticVoidMethod(env, cls, mainId, 0);
(*jvm)->DestroyJavaVM( jvm );
return 0;
}
I use the following command line in order to compile and link it:
bcc32.exe -IC:\JDK11~1.8\include -IC:\JDK11~1.8\include\win32 -LC:\JDK11~1.8\lib javai.lib test.c
but I always end up getting the same error message:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: 'C:\JDK1.1.8\LIB\JAVAI.LIB' contains invalid OMF record, type 0x21 (possibly COFF)