• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Call method using JNI

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i've created jni for a c++ program.

i wanted to call the c++ method in java and called it succesfully( i mean i have created a .h file which has the c++ header like JNIEXPORT etc.,)

i replaced the header or what ever is present in .h file created by java -jni <file name> in c++

but i get following error




i get the first error when i replace the method declaration with the following,
JNIEXPORT void JNICALL Java_phone_pjstart (JNIEnv *env, jobject ob)
and in the main method i call it as obj.pjstart()

i get the second error when in main method i put
obj.Java_phone_pjstart()

remember obj is the object of main class and not that is in (JNIEnv *env, jobject ob)



any suggestions

thanks in advance







 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be having problems calling C++ methods from other C++ methods; this isn't really a Java question, although the code is dealing with the JNI header files: it's just a C++ question. I am not sure why you think you can change the names of the methods (you can't) or leave out the arguments when you call a method (you can't.) Just as in all C++ code, just as in all Java code, you have to call the methods that are there, using the arguments that they require. I don't know what else to tell you.
 
bharani rao
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic