The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Java Native Interface
Lesson: Writing a Java Program with Native Methods

Step 6: Run the Program

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

java HelloWorld

You should see the following output:

Hello World!
If you see an exception like the following, then you don't have your library path set up correctly.
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)
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 Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.