🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1308

JNI: Compiling with C++ Builder Command Line Tools

#1308
From: Adolfo
Date: Mon, 25 Feb 2002 21:52
45 lines
2494 bytes
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;
  /* get CLASSPATH environment variable setting */
  char* szClasspath = getenv( "CLASSPATH" );
  vmargs.version = 0x00010001;  /* version 1.1 */
  JNI_GetDefaultJavaVMInitArgs( &vmargs ); /* init vmargs */
  /* the classpath returned by JNI_GetDefaultJavaVMInitArgs is wrong */
  vmargs.classpath = szClasspath;
  rc = JNI_CreateJavaVM( &jvm, &env, &vmargs );  /* create the JVM */
  if( rc < 0 )
    return 1;
  /* load the class containing the static main() method */
  cls = (*env)->FindClass( env, MAIN_CLASS );
  if( cls == 0 )
    return 1;
  /* find the main() method */
  mainId = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
  if( mainId == 0 )
    return 1; /* error */
  (*env)->CallStaticVoidMethod(env, cls, mainId, 0); /* call main() */
  (*jvm)->DestroyJavaVM( jvm ); /* kill the 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 BorlandError: 'C:\JDK1.1.8\LIB\JAVAI.LIB' contains invalid OMF record, type 0x21 (possibly COFF)
Technical Details
Message-ID: <3c7ab224$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!24.226.1.12!feed.cgocable.net!newsfeed.newzpig.com!intgwlon.nntp.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,845382a37d575919,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-02-25 14:05:44 PST
From: "Adolfo" <aaladro@ya.com>
Sender: "Adolfo" <aaladro@ya.com>
Reply-To: "Adolfo" <aaladro@ya.com>
Subject: JNI: Compiling with C++ Builder Command Line Tools
Newsgroups: borland.public.jbuilder.java.api
X-User-Info: 217.126.182.75 217.126.182.75    
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3c7ab224$1_2@dnews>
Date: 25 Feb 2002 13:52:36 -0800
X-Trace: dnews 1014673956 207.105.83.65 (25 Feb 2002 13:52:36 -0800)
Lines: 46
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!24.226.1.12!feed.cgocable.net!newsfeed.newzpig.com!intgwlon.nntp.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews