Connect Java Reference
Contents
About the PC*Miler Connect Standalone JNI wrapper
Starting with PC*Miler Connect 28, we are offering all of the source code to our existing Connect Java wrapper.
The JNI layer is directly integrated with our PC*Miler Connect dll, pcmsrv32.dll. Older versions of the jar file or even new versions built with existing Java code will still interface directly with pcmsrv32.dll (or pcmsrv64.dll). It is not mandatory to use this new standalone JNI layer. If you are satisfied with the current behavior, then you can bypass the rest of this document.
There is now the option to build a separate JNI layer dll and interface with that instead. This is beneficial as it will allow users to expand the Java wrapper to gain access to any PC*Miler Connect APIs we do not currently expose through the Java wrapper. The instructions below cover the steps necessary to configure, build, and deploy everything necessary to do that.
The Code
There are two sets of code provided now. The native Java code used to build the traditional Java jar file and the C++ JNI layer used to create the JNI wrapper dll for our C-style APIs provided in pcmsrv32.dll. All of this code is architected using standard JNI practices.
Java Layer
To use the standalone JNI wrapper there is only one change needed in the Java code.
- Open up
java/alk/connect/PCMSJava.java
in an editor of your choice. - Find the two
System.loadLibrary()
calls made at the top of thePCMSJava
class. By default they reference the standard PC*Miler Connect dlls. - Redirect them to point to the new standalone JNI wrapper dlls. The new names will be
pcmsrv32_jni_wrapper
andpcmsrv64_jni_wrapper
. The screenshots below show the changes needed. - Once these changes are made you can save and close
PCMSJava.java
. Navigate back to theJava.new
root folder and run01_build_jar.bat
. The Java code will be recompiled and a newalk.jar
will be put into theJava.new
folder.
C++ JNI Wrapper
The jni_wrapper
folder contains a MS Visual Studio 2005 project. If you’re using a newer version of MS Visual Studio, simply open the solution file in the jni_wrapper
folder and migrate it to your version of Visual Studio. Next, copy the pcmsrv32.lib
and pcmsrv64.lib
files from the Connect folder, which is stored within the PCMILER folder on your machine, and paste those files into the jni_wrapper
folder. This will provide you with all of the necessary files and source code used to build a standalone JNI wrapper dll for our PC*Miler Connect product.
There are no code edits required to get it to work out of the box. You only need to edit the code if you want to expose new PC*Miler Connect APIs through the Java wrapper. If you are not doing that, you can just run 02_build_jni_wrapper.bat
in the Java.new
folder. Two dlls will be produced in the Java.new
folder: pcmsrv32_jni_wrapper.dll
and pcmsrv64_jni_wrapper.dll
.
Deployment
Once the two components are built, deployment is very simple. As long as the PC*Miler Connect dll is accessible via a load library call, the jar and JNI wrapper dll can be put anywhere on the system. To verify this you can build and run our included PC*Miler Connect Java sample application. First you need to run 03_build_test.bat
and then 04_run_test.bat
to launch the test application.
The output of the test will be dumped to PCMSJavaTest_output.txt
. If the test succeeded, the output will contain a wide variety of API calls to calculate mileages, perform lookups, and run reports. (See attached reference guide for more information about the APIs.)