Previous | Next | Trail Map | Using the JNI | Step By Step

Step 6: Run the Program

Now run the Java application (the Main class) with the Java interpreter, as follows:

java Main
If you included the main routine within the HelloWorld class (as described in Step 1:Write the Java Code, then run it as follows:
java HelloWorld

In either case, you should see the following output:

Hello World!
If you see an exception like this one:
java.lang.UnsatisfiedLinkError: no hello in shared library path
        at java.lang.Runtime.loadLibrary(Runtime.java)
        at java.lang.System.loadLibrary(System.java)
        at 
        at java.lang.Thread.init(Thread.java)
then you don't have your library path set up correctly. The library path is a list of directories that the Java runtime system searches when loading libraries. Set your library path now, and make sure that the name of the directory where the hello library lives is in it.


Previous | Next | Trail Map | Using the JNI | Step By Step