JNI : converting a propertie to String/jstring

Discussion in 'Java' started by EExtasEE, Jan 23, 2005.

  1. EExtasEE

    EExtasEE Guest

    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,
     
    EExtasEE, Jan 23, 2005
    #1
    1. Advertising

  2. EExtasEE

    Alan Cabrera Guest

    Re: converting a propertie to String/jstring

    Won't this return the Properties object, not a string?

    Regards,
    Alan

    "EExtasEE" <> wrote in message
    news:41f428f7$0$26212$-internet.fr...
    > 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,
     
    Alan Cabrera, Jan 23, 2005
    #2
    1. Advertising

  3. EExtasEE

    EExtasEE Guest

    Re: converting a propertie to String/jstring

    Alan Cabrera a écrit :
    > Won't this return the Properties object, not a string?
    >
    > Regards,
    > Alan
    >
    > "EExtasEE" <> wrote in message
    > news:41f428f7$0$26212$-internet.fr...
    >
    >>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,

    >
    >
    >


    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)
     
    EExtasEE, Jan 24, 2005
    #3
  4. Re: converting a propertie to String/jstring

    On Mon, 24 Jan 2005 12:11:31 +0100, EExtasEE wrote:
    > 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

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Jan 24, 2005
    #4
  5. EExtasEE

    EExtasEE Guest

    Re: converting a propertie to String/jstring

    Gordon Beaton a écrit :
    > On Mon, 24 Jan 2005 12:11:31 +0100, EExtasEE wrote:
    >
    >>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
    >

    mouarf.
    Why is the life so hard ?
    Thank you for your answer mister gordon.
     
    EExtasEE, Jan 24, 2005
    #5
  6. EExtasEE

    Chris Uppal Guest

    Re: converting a propertie to String/jstring

    EExtasEE wrote:

    > > 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 ?


    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
     
    Chris Uppal, Jan 24, 2005
    #6
  7. EExtasEE

    EExtasEE Guest

    Re: converting a propertie to String/jstring

    Chris Uppal a écrit :
    > EExtasEE wrote:
    >
    >
    >>>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 ?

    >
    >
    > 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.
     
    EExtasEE, Jan 24, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kiran Kumar
    Replies:
    2
    Views:
    1,161
    Kiran Kumar
    Sep 23, 2003
  2. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    869
    Alex Hunsley
    Nov 4, 2003
  3. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    938
    Pasturel Jean-Louis
    Mar 3, 2004
  4. NOBODY
    Replies:
    14
    Views:
    2,918
    NOBODY
    Nov 1, 2005
  5. =?Utf-8?B?Um9u?=

    Profile Propertie Type

    =?Utf-8?B?Um9u?=, Jun 2, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    378
    =?Utf-8?B?Um9u?=
    Jun 2, 2006
Loading...

Share This Page