Java AWT Native Interface: Difference between revisions

Content deleted Content added
m Fixed grammar and language.
Create a Java application: I changed the tone or style to reflect the encyclopedic tone used in Wikipedia.
Line 17:
A complete walkthrough example of this technology is available on Wikibooks (see link below).
 
A comprehensive example demonstrating this technology is available on Wikibooks (refer to the link below).
=== Create a Java application ===
See the [[Java Native Interface]] article for an explanation of the <code>native</code> [[keyword (computer programming)|keyword]] and the <code>loadLibrary()</code> method. A <code>paint()</code> method will be simply invoked when the AWT [[event dispatching thread]] "repaints" the screen.
 
SeeTo begin, a Java application is created. The utilization of the [[Java Native Interface]] articleis forexplained anin explanationthe ofarticle. theThe <code>native</code> [[keyword (computer programming)|keyword]] and the <code>loadLibrary()</code> method. Aare integral components, while the <code>paint()</code> method will be simplyis invoked when the AWT [[event dispatching thread]] "repaints" the screen.
=== Create a C++ header file ===
Create the [[C++]] [[header file]] as usual. (See [[Java Native Interface]] for more complete explanations.)
 
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.
=== Implement the C++ native code ===
Type this in a file named "NativeSideCanvas.cpp" and compile into a library. See [[Java Native Interface]] (JNI) for a more complete explanation. (For [[Solaris (operating system)|Solaris]] code and other operating systems see links below.)
 
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.
=== Run the program ===
One should run the file as usual. One should then see a window with, for example, a rectangle drawn in it. (See [[Java Native Interface]] for complete instructions.)
 
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.
Note: One can notice that the AWT Native Interface requires the "jawt.dll" (or "jawt.so") to run with the application, so the easiest way to do that is copying the "jawt.dll". (should be in the .../jre/bin [[file path]] of the JDK's installation path.){{citation needed|date=June 2012}}
 
Note:It's Oneimportant canto noticenote that the AWT Native Interface requiresnecessitates the presence of the "jawt.dll" (or "jawt.so") file to run withalongside the application,. so theThe easiestsimplest waymethod to doensure thatthis is by copying the "jawt.dll". (shouldfile, typically befound in the .../jre/bin [[filedirectory path]] ofwithin the JDK's installation path.){{citation needed|date=June 2012}}
 
== Native painting ==