Listing 2
(a)
HelloWorld.h
const char* helloWorld();
(b)
HelloWorld.cpp
const char* helloWorld()
{
return "Hello World!";
}
(c)
HelloWorldExample.java
package noodleglue.examples.helloWorld;
public class HelloWorldExample
{
public static void main(String args[])
{
javax.swing.JFrame window = new javax.swing.JFrame();
//Make a region to display the text
javax.swing.JTextArea jTextArea = new javax.swing.JTextArea();
window.setContentPane(jTextArea);
//We call across static method into JNI land to get text
jTextArea.setText( HelloWorld.helloWorld() );
//Display Window with JNI bridged text
window.pack();
window.setVisible(true);
}
}