JNI : converting a propertie to String/jstring

E

EExtasEE

Hi everybody, i want to retrieve an enumeration of ALL JVM properties
but i got a problem converting Properties into jstring/string

jclass sys;
jmethodID met;
jstring ret;
jobject obj2;


//getting properties enumeration
sys = (*env)->FindClass (env, "java/lang/System");
met = (*env)->GetStaticMethodID (env, sys,
,getProperties","()Ljava/util/Properties;");
obj2 = (jstring)(*env)->CallStaticObjectMethod(env, sys, met);

return obj2;

value returned : h°'°'°'°'External.classPK

best regards,
 
E

EExtasEE

Alan Cabrera a écrit :
Won't this return the Properties object, not a string?

Regards,
Alan

obj2 = (jstring)(*env)->CallStaticObjectMethod(env, sys, met);<---this
doesn't mean that im making a cast into jstring format?(i have tried to
cast into jcharArray)
 
G

Gordon Beaton

obj2 = (jstring)(*env)->CallStaticObjectMethod(env, sys, met);<---this
doesn't mean that im making a cast into jstring format?(i have tried to
cast into jcharArray)

Casting does not magically convert the Properties object into a String
or any other type.

If you want to display the individual properties, you need to extract
them individually using methods provided by java.util.Properties.

/gordon
 
E

EExtasEE

Gordon Beaton a écrit :
Casting does not magically convert the Properties object into a String
or any other type.

If you want to display the individual properties, you need to extract
them individually using methods provided by java.util.Properties.

/gordon
mouarf.
Why is the life so hard ?
Thank you for your answer mister gordon.
 
C

Chris Uppal

EExtasEE said:
mouarf.
Why is the life so hard ?

If it were pleasant and easy to do then they wouldn't be paying you to do it...

(On the other hand, if you are writing JNI code and /not/ being paid for it,
then life is indeed hard ;-)

-- chris
 
E

EExtasEE

Chris Uppal a écrit :
EExtasEE wrote:




If it were pleasant and easy to do then they wouldn't be paying you to do it...

(On the other hand, if you are writing JNI code and /not/ being paid for it,
then life is indeed hard ;-)

-- chris

Im not paid to do that, im a student.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

jni libjvm sigsegv 1
JNI Error in passing array 0
JNI setproperty 3
JNI get exception object class name 1
JNI error with JDK 1.5 0
JNI error with JDK1.5 1
JNI Memory Loss? 1
JNI : accessing native array 0

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top