Help needed in JNI function call

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • parthan

    Help needed in JNI function call

    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

    #2
    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@in diatimes.com> wrote in message
    news:57fafdc3.0 310141952.3c05b 2d1@posting.goo gle.com...[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]


    Comment

    • Raymond DeCampo

      #3
      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

      Comment

      Working...