πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #669

Re: JNI setting properties

#669
From: DR
Date: Thu, 20 Jan 2005 16:15
47 lines
2254 bytes
your sig is wrong :
 > meth = (*env)->GetStaticMethodID (env, sys, "setProperty",
 > 
"(Ljava/lang/String;)Ljava/lang/String;","(Ljava/lang/String;)Ljava/lang/String;"); 


the right is :

(*env)->GetStaticMethodID (env, sys, "setProperty", 
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");


so, if a JNI method throw an exception you must clear it before call 
another one :

	(*env)->ExceptionClear(env);

=>
sys = (*env)->FindClass (env, "java/lang/System");
(*env)->ExceptionClear(env);

meth = (*env)->GetStaticMethodID (env, sys, "setProperty",
"(Ljava/lang/String;)Ljava/lang/String;");
(*env)->ExceptionClear(env);

...


zikfried a οΏ½crit:
> hi,
> i want to change my JVM properties("user.dir", "os.name" etc...) using JNI.
> So the setProperty() method have 2 parameters that's why i have tried to 
> do this :
> 
> sys = (*env)->FindClass (env, "java/lang/System");
> 
> meth = (*env)->GetStaticMethodID (env, sys, "setProperty", 
> "(Ljava/lang/String;)Ljava/lang/String;","(Ljava/lang/String;)Ljava/lang/String;"); 
> 
> 
> (*env)->CallStaticObjectMethod(env, sys, meth, (*env)->NewStringUTF 
> (env, &key),(*env)->NewStringUTF (env, &newVal));
> 
> I don't understand why it doesn't work.
> 
> Can anyone help me?
> Thanks by advance
Technical Details
Message-ID: <41EFD907.4000005@cnam.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-1.proxad.net!news5-e.free.fr!not-for-mail
References: <41efcf31@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,8df8ced784b178b6
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-1.proxad.net!news5-e.free.fr!not-for-mail
Message-ID: <41EFD907.4000005@cnam.fr>
Date: Thu, 20 Jan 2005 17:15:03 +0100
From: DR <droussea@cnam.fr>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: fr-fr, fr
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: JNI setting properties
References: <41efcf31@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 48
Organization: Guest of ProXad - France
NNTP-Posting-Date: 20 Jan 2005 17:15:00 MET
NNTP-Posting-Host: 82.232.74.233
X-Trace: 1106237700 news5-e.free.fr 9960 82.232.74.233:2947
X-Complaints-To: abuse@proxad.net