Home » Eclipse Projects » Rich Client Platform (RCP) » Environtment Variable issue
Environtment Variable issue [message #448434] |
Mon, 24 April 2006 14:53  |
Eclipse User |
|
|
|
Hello,
my native code searchs for a environtment variable using the common
getenv("variable") function. This variable must contain the path to the
java class. I'm not used to work with this, so I put the whole path ( in
unix /home/victor/workspace/plugin_name/bin/plugin/name/class ) but I get
the exception java.lang.NoClassDefFoundError. May I omit some part of the
path? I supose that getenv searches for compiled classes so I added the
/bin dir of the plugin instead the /src , I'm wrong?
I have tried with lots of diferent paths and no one worked.
I know it's a little hard question but if anyone that worked with
something similar could help me would be nice.
Thanks
|
|
| |
Re: Environtment Variable issue [message #448583 is a reply to message #448516] |
Thu, 27 April 2006 08:01   |
Eclipse User |
|
|
|
Hello Paul...
We are a 3 people team developing a GUI for R with eclipse rcp. R is a
stadistical aplication. After all we are not doing the whole comunication
between R and RCP, we use a engine, JRI, produced by the people of
www.rosuda.org (They made that but with Java AWT). Since this package is
GPL we can rehuse it :p
The idea is we don't have to touch their engine, our rcp has to be
independent of the model ( JRI ) so I can't touch their code...
The comunication is made by JNI, since R only understand C.
We toke their java side package and incrusted it with eclipse as a
pluguin, yo know, new plugin and link to local system...we use callbacks
to comunicate with R , for the graphical side ( what I'm in ) there is
another package: JavaGD, taken from rosuda too...
ok i explained a litle abaout all. now I'm crashed at the following point
and it's hard to solve the problem because when you use a code that is not
yours...:
when I changed JavaGD from the original path and put it into a new plugin,
the grafical side can't start because the C code searchs for:
findclass(env, "org/rosuda/javaGD/JavaGD") path to find JavaGD constructor
method (they create a JVM at C to comunicate with Javaside), and Console
outputs:
"Error at thread-1": class /org/rosuda/javaGD/JavaGD could not be found.
There are two environtment variables in the C code: CLASSPATH and
JAVAGD_CLASS_NAME.
CLASSPATH is the classpath option of the virtual machine JavaVMInitArgs
JAVAGD_CLASS_NAME is the main device class name to find, if no defined it
searchs for /org/rosuda/javaGD/JavaGD (explained before)
Well i'm finishing, the problem may be at the CLASSPATH I think. but I set
de variable at the eclipse run configuration and it don't find the class
even if I set the CLASSPATH to /home/victor and I put the class
there...It's a paths issue I think.
Have you read all this Paul? xDD
Anyone can help me?
Everyone that reads that is a great man/woman!
Thanks!!!
|
|
|
Re: Environtment Variable issue [message #448589 is a reply to message #448583] |
Thu, 27 April 2006 08:38   |
Eclipse User |
|
|
|
Victor Llorens wrote:
>
> when I changed JavaGD from the original path and put it into a new
> plugin, the grafical side can't start because the C code searchs for:
> findclass(env, "org/rosuda/javaGD/JavaGD") path to find JavaGD
> constructor method (they create a JVM at C to comunicate with Javaside),
> and Console outputs:
OK, their JNI code is talking to the JVM instance to find a class. How
was their JNI code accessed?
If you start up a plugin, and the plugin makes a JNI call, and the JNI
code uses findClass(*), the JNI call has full access to the plugin
classpath. That means it honours the OSGi bundle classpath rules.
If a C thread makes a call into a JVM that it accessed somehow or
created itself, it doesn't have access to the plugin classpath, only the
main system classpath (which in an eclipse app is almost always just
startup.jar).
If you have the first scenario, then is the JavaGD class in the same
plugin as the JNI libs and their java classes?
Later,
PW
|
|
| | | | |
Re: Environtment Variable issue [message #448900 is a reply to message #448893] |
Sat, 06 May 2006 22:41   |
Eclipse User |
|
|
|
Hi,
I could have said this before but their aplication is a set of plugins
(not eclipse plugins). So JavaGD is independent and it doesn't need
anything of the remainig aplication. The aplication is independent of
JavaGD too (if not installed R uses X11 Device as default).
they get env attaching to the current JVM ( There's two created (eclipse
one, RCP one) but I supose it always attaches with the RCP one since it
worked well before transporting the package to a new plugin). I attach
the code . JavaVM *jvm variable is set before to 0; the first time I
invoke de class in my RCP it's value is 0, after that, in future invokings
is, well, 1 ...:
static JNIEnv *getJNIEnv() {
JNIEnv *env;
jsize l;
jint res;
if (!jvm) {
res= JNI_GetCreatedJavaVMs(&jvm, 1, &l);
if (res!=0) {
fprintf(stderr, "JNI_GetCreatedJavaVMs failed! (%d)\n",res);
return 0;
}
if (l<1) {
fprintf(stderr, "JNI_GetCreatedJavaVMs said there's no JVM
running!\n"); return 0;
}
}
res = (*jvm)->AttachCurrentThread(jvm, &env, 0);
if (res!=0) {
fprintf(stderr, "AttachCurrentThread failed! (%d)\n",res); return
0;
}
return env;
}
I have had fun printing to eclipse console all steps of the C code (with
fprintf(stderr,"",var) ) and definetly it fails at the first FindClass,
and at all the rest because c variable is always 0.
|
|
| | |
Re: Environtment Variable issue [message #449619 is a reply to message #448583] |
Tue, 16 May 2006 18:39  |
Eclipse User |
|
|
|
Hello,
finally I have solved the problem. I have done it this way:
- I named the new plugin identically as the package name.
- I didin't delete any files from the new package created. There is one
called *Plugin.java that seems to be important for this to work. In the
other plugins I deleted it and they work fine...
- I pasted my original classes inside the new package.
- I exported the package from the new plugin.
- I added the new plugin as a dependency of org.rosuda.JRI plugin.
But this is the problem: JavaGD needs JRI too. If I add javaGD as a
dependency for JRI in order to JNI recognize JavaGD path, eclipse there's
a cycle in the arquitechture...
Any ideas?
Thanks
|
|
|
Goto Forum:
Current Time: Sun Aug 31 04:22:57 EDT 2025
Powered by FUDForum. Page generated in 0.10996 seconds
|