By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,499 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,499 IT Pros & Developers. It's quick & easy.

Help needed in JNI function call

P: n/a
We are running our c++ program as Windows services which uses JNI.
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.

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <sa*********@indiatimes.com> wrote in message
news:57**************************@posting.google.c om...
We are running our c++ program as Windows services which uses JNI.
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.

Jul 17 '05 #2

P: n/a
parthan wrote:
We are running our c++ program as Windows services which uses JNI.
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.


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

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.