RE: accessing java string

2001-03-07 Thread w. Terry Lincoln

And the Linux connection is what?

 -Original Message-
From: soonho [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 06, 2001 11:50 PM
To: java-linux
Subject: accessing java string


Hi all,

I created a JVM (JNI_CreateJavaVM), then now I would like to accessing
java string through GetStringUTFChars.
Before I can use GetStringUTFChars, I have to FindClass and GetMethodID?

Since GetStringUTFChars(env, string, isCopy) is so simple, doesn't
involve methodID and so on, I don't know how this string can be passed
to native program.

For example, i wanna to get java string s1 from java side. My C native
side have to assign jstring s1? How it can get jstring from java? Java
have to return String s1?

Thank you

soonho


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: accessing java string

2001-03-07 Thread Joi Ellis

On Wed, 7 Mar 2001, soonho wrote:

> Hi all,
> 
> I created a JVM (JNI_CreateJavaVM), then now I would like to accessing java string 
>through GetStringUTFChars.

> Before I can use GetStringUTFChars, I have to FindClass and GetMethodID?

Maybe.  You have to possess a pointer of type JString from somewhere. 
Your C can use FindClass and GetMethodID if it wants to call a java method.
(I haven't had to do this yet and my JNI books are at work so I'm going on
memory here.)  You may want to find an object and access a String field on
that object.  Without knowing more about your code it's impossible to say.
 
> Since GetStringUTFChars(env, string, isCopy) is so simple, doesn't involve methodID 
>and so on, I don't know how this string can be passed to native program.

In my case, my Java app is calling a C layer to access a shared C library.
So I have a Class which defines a bunch of native methods into my C layer.
So, my C code is called and recieves a pointer to JString.  The C turns around
and calls GetSTringUTFChars to convert the unicode JString into a UTF-8 string
C can handle.

> For example, i wanna to get java string s1 from java side. My C native side have to 
>assign jstring s1? How it can get jstring from java? Java have to return String s1?

How you acquire a pointer to JString is up to your code.  You could find and
call a Java method which returns the JString, you could call a Java method
which issues a callback to a function of your own which receives the JString
as a parameter, or you could read the JString from an object's fields.

Perhaps if you posted a snippet of java code which contains that string, we
could make some more specific suggestions.

-- 
Joi EllisSoftware Engineer
Aravox Technologies  [EMAIL PROTECTED], [EMAIL PROTECTED]

No matter what we think of Linux versus FreeBSD, etc., the one thing I
really like about Linux is that it has Microsoft worried.  Anything
that kicks a monopoly in the pants has got to be good for something.
   - Chris Johnson


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Java very slow on linux 2.4

2001-03-07 Thread Vijaykumar Krishnaswamy


Hi ,
i recently installed linux2.4.2 on my machine and ever since i am
finding that the java performance has significantly dropped down. Is there
ia reason for this?. If so can it be fixed. Please let me know.

thanks a lot,
vijay


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]