PathEngine home previous: Parameter Type Mappingsnext: Applying the SDK
Contents, Programmers Guide, Using PathEngine with Other Languages, Java Native Interface, Running the Examples

Running the Examples

The Java side of PathEngine's Java API can be found in 'SDKRoot/java'. The interface classes and associated helpers (in the com.pathengine package) are then located in 'SDKRoot/java/com/pathengine', and some additional example class are located in 'SDKRoot/java/com/pathengine'.

You can build the com.pathengine package by changing directory to SDKRoot/java, and then typing 'javac com/pathengine/*.java'. And you can then build the example classes with 'javac com/pathengine/example/*.java'.

Example classes

Two console applications examples are provided, com.pathengine.example.QuickStart and com.pathengine.example.LinkageDetails.

The QuickStart application shows you how to get up and running with the SDK in Java with the most commonly used API calls for loading a ground mesh and performing some pathfinding.

The LinkageDetails application is then designed to demonstrate some detail issues relating to the Java API mapping (such as error handling, interface object comparison, out argument passing and lifetime management).

An example callback implementation for the PathEngine content processing method is also shown, in com.pathengine.example.SquareMesh.

Running the examples

A quick way to run the examples is to run Java from SDKRoot/java, with the java library path set to the relevant build target directory, as follows:

~/PathEngine/sdk/java $ java -Djava.library.path=../build/GCCx64/Debug/so com.pathengine.example.QuickStart
start: 56:1070,270
goal: 0:630,491
Path found with 4 points:
56:1070,270
15:977,270
62:785,377
0:630,491
        

The application will need to load 'libPathEngine_JNI.so' (which you should have built based on the instructions here). If a shared object file with this name is not present, or if the library path is not set appropriately, then you will see something like this:

~/PathEngine/sdk/java $ java com.pathengine.example.QuickStartException in thread "main" java.lang.UnsatisfiedLinkError: no PathEngine_JNI in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
	at java.lang.Runtime.loadLibrary0(Runtime.java:849)
	at java.lang.System.loadLibrary(System.java:1087)
	at com.pathengine.SDK.<clinit>(SDK.java:8)
	at com.pathengine.example.QuickStart.main(QuickStart.java:10)
        

Documentation for PathEngine release 6.04 - Copyright © 2002-2024 PathEnginenext: Applying the SDK