Java AWT Native Interface: Difference between revisions

Content deleted Content added
update
Line 12:
 
The AWT Native Interface is very similar to the JNI, and the steps are the same as those of the JNI. See the [[Java Native Interface]] article for an explanation of the JNI techniques employed by the AWT Native Interface. The AWT Native Interface was added to the [[Java platform]] with the [[Java Platform, Standard Edition|J2SE]] 1.3 ("Kestrel") version.
 
== AWT Native Interface steps ==
{{howto|date=June 2012}}
A complete walkthrough and demonstrating example of this technology is available on Wikibooks (see link below).
 
To begin, a Java application is created. The utilisation of the Java Native Interface is explained in the article. The native keyword and the loadLibrary() method are integral components, while the paint() method is invoked when the AWT event dispatching thread repaints the screen.
 
Following the creation of the Java application, a C++ header file is generated conventionally. Detailed explanations can be found in the Java Native Interface documentation.
 
Next, the C++ native code is implemented, typically in a file named "NativeSideCanvas.cpp," and compiled into a library. Further information on this process is provided in the Java Native Interface (JNI) documentation.
 
Once the program is constructed, it can be executed as per usual. Upon running the file, a window should appear, displaying, for example, a drawn rectangle. Detailed instructions can be found in the Java Native Interface documentation.
 
It's important to note that the AWT Native Interface necessitates the presence of the "jawt.dll" (or "jawt.so") file to run alongside the application. The simplest method to ensure this is by copying the "jawt.dll" file, typically found in the .../jre/bin directory within the JDK's installation path.
 
== Native painting ==