Article View: borland.public.jbuilder.java.language
Article #8457JNI Question: Calling java methods from c (not callbacks)
From: Ricard Gonzalez Bringue
Date: Thu, 22 Mar 2001 08:28
Date: Thu, 22 Mar 2001 08:28
30 lines
2108 bytes
2108 bytes
Hi Everybody, I'm a newbie at Java Native Code. I would like to know how to call java methods from C, without creating the JVM from the native side, I have the following system: Client C native DLL Java Application I would like to make the java application behave as a server so it could attend the client requests (from C). My order of execution is: 1. Start java application. 2. Java loads the DLL. 3. Java can make invocations of DLL methods, in fact it does. 4. The problem, I would like to enable C client to use DLL and call java methods. In the sample from Sun, Java calls C native methods and then this function calls back Java. This function uses JNIEnv and jobject passed by parameter so it has no problem in calling Java again. The problem is, how to call Java methods from C native code. I tried to saved the parameters JNIEnv and jobject and saved it as public variables, so that any function can use it and make a Java method invocation, but it doesn't work. I'm using jdk1.3.System Operating is Windows NT. What am I doing wrong?? Must I start the JVM from the native side?? Thank you in advance. Ricard
Technical Details
Message-ID:
<3AB9B790.421AA49B@eq.upc.es>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!newspump.monmouth.com!newspeer.monmouth.com!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!147.83.141.185Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,e5c82d4cfa4e0f3 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-23 04:06:05 PST Message-ID: <3AB9B790.421AA49B@eq.upc.es> Date: Thu, 22 Mar 2001 09:28:01 +0100 From: Ricard Gonzalez Bringue <gonzalez@eq.upc.es> X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: JNI Question: Calling java methods from c (not callbacks) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 147.83.141.185 X-Trace: 22 Mar 2001 00:28:02 -0800, 147.83.141.185 Lines: 31 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!newspump.monmouth.com!newspeer.monmouth.com!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!147.83.141.185