Java Native Access

Java Native Access

Java Native Access (JNA) ist eine Java-Programmbibliothek für den Zugriff auf plattformspezifische ("native") dynamische Programmbibliotheken (DLL in Windows). Hierbei muss im Unterschied zu JNI kein plattform-spezifischer Code geschrieben werden.

JNA ist in der Funktion mit den Platform Invocation Services (P/Invoke) von .NET vergleichbar. Es unterstützt eine automatische Umwandlung zwischen einigen C- und Java-Datentypen. Die erforderliche Java-Mindestversion ist 1.4.

Inhaltsverzeichnis

Lizenz

LGPL Version 2.1 oder höher.

Anwendungen

Die folgenden Softwareprojekte verwenden JNA:

Beispiel

Das folgende Beispiel lädt die Standard C Library um die printf-Funktion aufzurufen. Dieses Beispiel funktioniert auf Microsoft Windows und Linux / Unix / Mac OS X.

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
 
/** Einfaches Beispiel einer Deklaration und Nutzung einer Dynamischen Programmbibliothek. */
public class HelloWorld {
  public interface CLibrary extends Library {
    CLibrary INSTANCE = (CLibrary)
    Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),
        CLibrary.class);
 
    void printf(String format, Object... args);
  }
 
  public static void main(String[] args) {
    CLibrary.INSTANCE.printf("Hello, World\n");
    for (int i=0;i < args.length;i++) {
      CLibrary.INSTANCE.printf("Argument %d: %s\n", i, 
         args[i]);
    }
  }
}

Weblinks


Wikimedia Foundation.

Игры ⚽ Поможем написать реферат

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Java Native Access — Infobox Software name = Java Native Access caption = developer = latest release version = 3.0.5 latest release date = release date|2008|08|14 latest preview version = latest preview date = operating system = Cross platform size = 606.9 KB… …   Wikipedia

  • Java Native Interface — (JNI) ist eine standardisierte Anwendungsprogrammierschnittstelle zum Aufruf von plattformspezifischen Funktionen bzw. Methoden aus der Programmiersprache Java heraus. Ein Java Programm, das JNI Aufrufe verwendet, ist nicht mehr… …   Deutsch Wikipedia

  • Java Native Interface — (JNI)  стандартный механизм для запуска кода, под управлением виртуальной машины Java (JVM), который написан на языках С/С++ или Ассемблера, и скомпонован в виде динамических библиотек, позволяет не использовать статическое связывание. Это… …   Википедия

  • Java Native Interface — JNI redirects here. For the city in the province of Buenos Aires, see Junín, Buenos Aires. The Java Native Interface (JNI) is a programming framework that enables Java code running in a Java Virtual Machine (JVM) to call and to be called[1] by… …   Wikipedia

  • Java Native Interface — Le JNI (Java Native Interface) est un framework qui permet au code Java s exécutant à l intérieur de la JVM d appeler et d être appelé[1] par des applications natives (c est à dire des programmes spécifiques au matériel et au système d… …   Wikipédia en Français

  • Java AWT Native Interface — is an interface for the Java programming language that enables rendering libraries compiled to native code to draw directly to a Java Abstract Window Toolkit (AWT) Javadoc:SE|java/awt|Canvas object drawing surface.The Java Native Interface (JNI)… …   Wikipedia

  • Java Virtual Machine Tools Interface — (JVMTI, or more properly, JVM TI) was introduced in J2SE 5.0 ( Tiger ). This interface allows a program to inspect the state and to control the execution of applications running in the Java Virtual Machine (JVM). JVMTI is designed to provide an… …   Wikipedia

  • Java performance — Programs written in Java have had a reputation for being slower and requiring more memory than those written in natively compiled languages such as C or C++ (see e.g. [cite web url=http://www.jelovic.com/articles/why java is slow.htm title=Why… …   Wikipedia

  • Java OpenGL — Infobox Software name = JOGL (JSR 231) caption = A demo screenshot illustrating real time refraction using JOGL on Mac OS X developer = Sun Microsystems Game Technology Group latest release version = 1.1.1 latest release date = May 22, 2008… …   Wikipedia

  • Comparison of Java and C++ — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”