Compiling and running the examples


Prerequisites

This has been tested with latest Eclipse on Windows, Mac and Linux.

The JNAOqi SDK requires a native library to work called jnaoqi. This library should work with any JRE greater than 1.6.

Configuring eclipse

Step Action
Create a new Java project as usual.

Import one of the examples files from the Java SDK as a new source.

../../_images/java_eclipse-import-src.png ../../_images/java_eclipse-import-src-2.png ../../_images/java_eclipse-import-src-3.png

Edit your project properties:

Java Build Path > Add External Jar... > select the jnaoqi.jar file.

../../_images/java_eclipse-add-jar.png

Edit jnaoqi.jar properties:

Refresh the project, right-click on the jnaoqi.jar reference, and choose properties.

../../_images/java_eclipse-add-jar-3.png

Select Native Library > Location Path > External folder ...

Then select the lib/ directory of the java SDK.

../../_images/java_eclipse-add-jar-4.png

You should probably change the NAOQI_IP constant in the examples for the examples to work

Please make sure to either use:

  • the IP of a robot where NAOqi is running or
  • “127.0.0.1” with a NAOqi running on your desktop, either from the C++ SDK, or from Choregraphe or a simulator.

Not using eclipse?

In order for Java to find the native library, you have to set the java property java.library.path. for further details, refer to the documentation of your IDE.

If you want to run your code from the command line, use something like:

java -Djava.library.path=/path/to/jnaoqi/lib -cp lib/janaoqi.jar:. SayHello