Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compiling with C++ Builder Command Line Tools

843829Feb 23 2002 — edited Nov 2 2004
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)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2004
Added on Feb 23 2002
5 comments
294 views