Passing String into Pointer parameter.

110 views
Skip to first unread message

Prasun

unread,
Mar 2, 2012, 10:41:20 PM3/2/12
to Java Native Access
Dear sir,
I have a struct

struct test{

char *pCarrierName;
}

And the following is the JNA Equivalent-

public static class Test extends Structure {

public Pointer pCarrierName;
public test( Pointer pCarrierName) {

super();

this.pCarrierName = pCarrierName;


}
}

Now i want to pass java String argument like this-

Test ob = new Test("Dry Air");

But it throws error because here i passed Java String and the
Constructor of Test Class Accept a pointer. How can i convert "Dry Air
" String as a Pointer and Pass into the Test Class Constructor.

Timothy Wall

unread,
Mar 3, 2012, 12:46:56 PM3/3/12
to jna-...@googlegroups.com
Use "String" as the structure field type rather than Pointer.
Reply all
Reply to author
Forward
0 new messages