Connecting Tech Pros Worldwide Forums | Help | Site Map

Help needed in JNI function call

parthan
Guest
 
Posts: n/a
#1: Jul 17 '05
We are running our c++ program as Windows services which uses JNI.[color=blue]
> Program is getting CLASSPATH env variable correctly and also
> initializes JVM successfully. After initializing JVM, programs makes a
> JNI call FindClass() for getting java class.But FindClass method
> returns NULL even though java class exists in the CLASSPATH.
>
> Same program when is run from command window, FindClass method call is
> working fine.
>
> Is there any difference between running a program thru command window
> and as a windows service ?
> Incase you have any idea on how to resolve this issue, kindly get back
> ASAP.[/color]

James
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Help needed in JNI function call


The thought that comes to mind is that as a service, other services or
programs it expects to be there might not be running yet when it launches.
JNI seems to not be initialized properly yet when your program comes up as a
service.
"parthan" <sarathymail@indiatimes.com> wrote in message
news:57fafdc3.0310141952.3c05b2d1@posting.google.c om...[color=blue]
> We are running our c++ program as Windows services which uses JNI.[color=green]
> > Program is getting CLASSPATH env variable correctly and also
> > initializes JVM successfully. After initializing JVM, programs makes a
> > JNI call FindClass() for getting java class.But FindClass method
> > returns NULL even though java class exists in the CLASSPATH.
> >
> > Same program when is run from command window, FindClass method call is
> > working fine.
> >
> > Is there any difference between running a program thru command window
> > and as a windows service ?
> > Incase you have any idea on how to resolve this issue, kindly get back
> > ASAP.[/color][/color]


Raymond DeCampo
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Help needed in JNI function call


parthan wrote:[color=blue]
> We are running our c++ program as Windows services which uses JNI.
>[color=green]
>>Program is getting CLASSPATH env variable correctly and also
>>initializes JVM successfully. After initializing JVM, programs makes a
>>JNI call FindClass() for getting java class.But FindClass method
>>returns NULL even though java class exists in the CLASSPATH.
>>
>>Same program when is run from command window, FindClass method call is
>>working fine.
>>
>>Is there any difference between running a program thru command window
>>and as a windows service ?
>>Incase you have any idea on how to resolve this issue, kindly get back
>>ASAP.[/color][/color]

There is a great deal of difference between running as a service and
running in the command window.

First of all, consider who the service is running as. Is it the same
user as you are using to run the command prompt?

Second, consider that the service does not "log in" before it is
executed. This can cause some environmental differences. (E.g., when
you log in, your administrator may have set up a number of mapped drives
that are automatically activated. If no one is logged in, the drives
are not mapped.)

In your specific problem, I recommend attempting to discover if the
class can be loaded within "standard" java (i.e no JNI) using a
reference to the class and then using Class.forName().

Ray

Closed Thread