[231] in java-interest
Re: Re: Native Methods Question
daemon@ATHENA.MIT.EDU (Kevin Collins)
Thu Jun 8 04:16:16 1995
Date: Wed, 7 Jun 1995 11:28:15 -0600
From: Kevin Collins <kevinc@hppcih58.fc.hp.com>
To: cmcmanis@scndprsn.Eng.Sun.COM, java-interest@java.Eng.Sun.COM
Cc: chrisk@hppcih58.fc.hp.com, detlef@hppcih58.fc.hp.com
Thanks for the help, I have some more questions ...
>>2) If the answer to #1 is yes, then how can I write a single program
>> that "knows" things like which separator to use?
>
> Because the C code is compiled for a specific platform, you know at
> runtime what the separator should be. For example if you were compiling
> the C code to run on a Solaris machine you would set them one way, if
> you were compiling on an NT machine you would set them another. I
> guess another way to say that is your "single" program would run on
> only a "single" platform, not all possible Java runtimes.
>
> Native code is NEVER dynamically downloaded and run and it is not portable.
I was trying to figure out how this "miracle happens here" was occurring.
Let me ask a few more questions along this line :
1) "NEVER ..."
How is native code called? Continuing with the File example, is the
native method executed back on the server via some type of invocation
from the client? I wish there was a picture of this in the documentation :)
If it is not invoked on the server, is the implication that the code,
and therefore the Java class, are only useful to browsers running on
the same platform as the native code was compiled?
If native code is not somehow portable, then why/when/where would
I want to use native code?
> So if you wished to distribute a class that had some native methods you
> would have to have shared library objects for every platform that you
> support. The Java code trys to supply Java interfaces to everything you
If I had separate libraries for all platforms available it would select
the library based upon the platform of the browser?
> need so that you can avoid this but in some cases where specific hardware
> or native libraries need to be interfaced too it is unavoidable.
>
If I wanted to encapsulate an existing C library what would you think
about just creating a message-based interface to it and communicating
with it via Java networking calls only? Is this a reasonable approach?
Could it be supported by the Java networking classes? Is there an
obviously easier way?
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com