This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes JNI mapping pointer to C++ structures to the java side (Really Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JNI mapping pointer to C++ structures to the java side (Really" Watch "JNI mapping pointer to C++ structures to the java side (Really" New topic
Author

JNI mapping pointer to C++ structures to the java side (Really

Shailaja Murty
Greenhorn

Joined: Mar 22, 2003
Posts: 4
> Problem in detail:
> I have a Struct* to be passed from C++ to java.
> I have got a C++ library that uses a structure, say myStruct*
> Let us say there are 2 C++ functions with the following signatures:
> struct myStruct*structInit();
> void doSomething(myStruct*);
> I want to write a java program that calls structInit(), gets myStruct*and
> passes this struct*to doSomething. How do I go about it?
> I tried making it global in the JNI code and instead of passing it back to
> java, tried calling functions that modify/access Struct* in JNI code
> itself.... using functions like
> struct myStruct* somevar;
> void structInit() { ...}
> void doSomething() {..}
> Though this works in a java application. It does not work on the
> browser(using JSP and javaBeans)...when multiple requests are being
> served.
> The path the code follows is
> HTML file takes some input and makes a call to JSP which stores the input
> data in a java bean and makes JNI calls to C++ code above and displays the
> data in the browser. While debugging the entire code, I found the problem
> lies in the struct * pointer variable being accessed globally. The system
> crashes saying it references a wrong memory location.
> I would really appreciate if you could suggest me with some
> solution...some tips or some sample programs... I have been going through
> lot of JNI documentation but that does not seem to help me much.
> Email address for communication: kshailaja@angelfire.com
> <mailto:kshailaja@angelfire.com>
> -Shailaja
Reply Reply All Forward Delete Previous Next Close

------------------
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
Shailaja
The javaranch has a naming policy and your login name does not meet the requirement.
Please signup again with a proper name.
Thanks..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNI mapping pointer to C++ structures to the java side (Really
 
Similar Threads
Angelfire.com....quiz 2
Angelfire.com....quiz 2
JNI crashes calling into C methods with structs
JNI question
Object References in JAVA. (Coming from C++)