Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Java Native Interface
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Objectives == JNI enables programmers to write native methods to handle situations when an application cannot be written entirely in the Java programming language, e.g. when the standard Java [[class (computer science)|class]] [[Library (computer science)|library]] does not support the platform-specific features or program library. It is also used to modify an existing application (written in another programming language) to be accessible to Java applications. Many of the standard library classes depend on JNI to provide functionality to the developer and the user, e.g. file I/O and sound capabilities. Including performance- and platform-sensitive API implementations in the standard library allows all Java applications to access this functionality in a safe and platform-independent manner. The JNI framework lets a native method use Java [[object (computer science)|objects]] in the same way that Java code uses these objects. A native method can create Java objects and then inspect and use these objects to perform its tasks. A native method can also inspect and use objects created by Java application code. Only applications and signed applets can invoke JNI. An application that relies on JNI loses the platform portability Java offers (a partial workaround is to write a separate implementation of JNI code for each platform and have Java detect the operating system and load the correct one at runtime). Not only can native code interface with Java, it can also draw on a Java {{Javadoc:SE|java/awt|Canvas|module=java.desktop}}, which is possible with the [[Java AWT Native Interface]]. The process is almost the same, with just a few changes. The Java AWT Native Interface is only available since [[Java Platform, Standard Edition|J2SE]] 1.3. JNI also allows direct access to [[Assembly language|assembly code]], without even going through a [[C (programming language)|C]] bridge.<ref>{{cite web | url = http://today.java.net/pub/a/today/2006/10/19/invoking-assembly-language-from-java.html | title = Invoking Assembly Language Programs from Java | publisher = Java.net | date = 2006-10-19 | access-date = 2007-10-06 | url-status = dead | archive-url = https://web.archive.org/web/20080330002620/http://today.java.net/pub/a/today/2006/10/19/invoking-assembly-language-from-java.html | archive-date = 2008-03-30 }}</ref> Accessing Java applications from assembly is possible in the same way.<ref>{{ cite web | url = http://today.java.net/pub/a/today/2007/10/04/launch-java-applications-from-assembly-language-programs.html | title = Launch Java Applications from Assembly Language Programs | publisher = Java.net | date = 2006-10-19 | access-date = 2007-10-04 | url-status = dead | archive-url = https://web.archive.org/web/20071011014140/http://today.java.net/pub/a/today/2007/10/04/launch-java-applications-from-assembly-language-programs.html | archive-date = 2007-10-11 }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)