'JNIEnv' not declared in this scope

Vrihad Shoonya vrihad@myway.com
Wed Feb 19 12:33:00 GMT 2003



Dear pals,

I am trying to compile kaffe oji plugin for phoenix which is
a browser derived from mozilla. Since the plugin was meant to
be for an older version of mozilla, Makefiles were broken.
So I decided to compile each program file individually. 
My gcc version is 3.2 and I am using Linux 2.4.18.

While compiling ojiPlugin.cpp using following command

gcc -g -c -fPIC -I /mnt/mozilla/include/string\
-I /mnt/mozilla/include/caps -I/mnt/mozilla/include/java \
-I/mnt/mozilla/include/pref  -I/mnt/mozilla/include/plugin \
-I/mnt/mozilla/include/xpcom  -I/mnt/mozilla/include/oji \
-I/mnt/mozilla/include -I/mnt/mozilla/include/nspr \
-I/opt/kaffe/include -I/opt/kaffe/include/kaffe \
-I/usr/X11R6/include ojiPlugin.cpp

I got following error:

In file included from ojiPlugin.h:29,
                 from ojiPlugin.cpp:25:
/mnt/mozilla/include/oji/nsIJVMPlugin.h:93: `JNIEnv' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:93: `jenv' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:93: `jint' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:93: parse error before `,' token
/mnt/mozilla/include/oji/nsIJVMPlugin.h:103: `JNIEnv' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:103: `proxyEnv' was not declared in
   this scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:103: parse error before `*' token
/mnt/mozilla/include/oji/nsIJVMPlugin.h:113: `JNIEnv' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:113: `jenv' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:113: `jobject' was not declared in this
   scope
/mnt/mozilla/include/oji/nsIJVMPlugin.h:113: parse error before `,' token
In file included from ojiPluginInstance.h:26,
                 from ojiPlugin.h:30,
                 from ojiPlugin.cpp:25:
/mnt/mozilla/include/oji/nsIJVMPluginInstance.h:32: `jobject' was not declared
   in this scope
/mnt/mozilla/include/oji/nsIJVMPluginInstance.h:32: `result' was not declared
   in this scope
/mnt/mozilla/include/oji/nsIJVMPluginInstance.h:32: virtual outside class declaration
......
<snip>

Apparently the identifiers like JNIEnv etc. are declared in a
file included from jni.h which is included from ojiPlugin.h.
JNIEnv is a typedef defined in jni.h as:

<snip>
......
/*
 * JNI Native Method Interface.
 */

struct JNINativeInterface_;

struct JNIEnv_;

#ifdef __cplusplus
typedef JNIEnv_ JNIEnv;
#else
typedef const struct JNINativeInterface_ *JNIEnv;
#endif
.....
<snip>

I am not sure why the error pertaining to scope is being
raised here. How can I rectify this problem without modifying
jni.h (as my present binary of mozilla is derived from the
codebase containing this file)?

I have noticed a posting of the same problem in java-prs.
See http://gcc.gnu.org/ml/java-prs/2000-q2/msg00357.html
But no one has responded to it so far.

Thanks in advance.
Vrihad

PS: C++ programming is pretty new to me.

_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com



More information about the Gcc-help mailing list