0% found this document useful (0 votes)
7 views2 pages

How To Compile JAVA API On Raspberry Pi 1

Uploaded by

roger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

How To Compile JAVA API On Raspberry Pi 1

Uploaded by

roger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Compile Mercury API - JAVA on

Raspberry Pi
_________________________________
Introduction
This document contains the steps to compile the ThingMagic® Mercury API Java on Raspberry Pi.

Tested On: Raspberry Pi 2

Steps
Note: Use sudo (root user) to compile and run the Mercury API

1. Download latest version of Java from Oracle website.

2. Copy downloaded file into Raspberry Pi.

3. Untar the file:

command: tar xvf <location to the file>

example: tar xvf jdk-8u101-linux-arm32-vfp-hflt.tar.gz

4. Add Java installed location /etc/profile file as shown below:

example: export JAVA_HOME=/home/debian/jdk1.8.0_101

export PATH=$PATH:$JAVA_HOME/bin

Then save the file and reboot the reader.

5. Check if Java is installed with the following commands:

command: which java, java -version, java , javac

6. Download the latest Mercury API available from the JADAK website using the below link:

https://www.jadaktech.com/documentation/rfid/mercuryapi/

7. Extract the API SDK.

command: tar <mercuryapi XXXX>

November 30, 2018 1


8. Edit the sample Java application (example:read.java) and comment out the line
“PACKAGES=samples;”. Then save the file.

9. Compile the application using the following command:

command: javac -cp .:ltkjava-1.0.0.6.jar:mercuryapi.jar <sampleapplication.java>

example: javac -cp .:ltkjava-1.0.0.6.jar:mercuryapi.jar read.java

**Note- The general error you could see is when Java complains about missing linux-arm.lib. When
this error occurs, it can't find the required libraries for using the serial ports on your system. Here is
how to recompile them:

• First, the C folder of the Mercury API contains a folder:

c/proj/jni

• That has the Makefile for compiling the proper lib driver.
• Next, find the jni.h file on your system:

$ sudo find / -name "jni.h"

which will result in - /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/include/jni.h

add that directory to the Makefile.jni like this:

CFLAGS += -I/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/include -I/usr/lib/jvm/jdk-8-oracle-arm32-vfp-


hflt/include/linux (jni.h needs a file called jni_md.h, hence the 2nd include)

• Run make command make -f Makefile.jni. This will result a file named libSerialTransportNative.so.0,
which you will rename to linux-arm.lib
• Now, traverse back to mercuryapiX.X.X/java
• Extract the mercuryapi.jar file using command jar xf mercuryapi.jar or use the instructions available
at https://docs.oracle.com/javase/tutorial/deployment/jar/unpack.html
• Now you will have a folder named “com” in the current(java) folder.
• Copy the mercuryapi.jar file from the Java directory into com/thingmagic.
• Copy the linux-arm.lib file you created before into java/com/thingmagic (there are a few other .lib
files there).

10. Run the application using the following command:

command: java -cp .:ltkjava-1.0.0.6.jar:mercuryapi.jar <sampleapplication> <comport> <--ant 1,2>

example: java -cp .:ltkjava-1.0.0.6.jar:mercuryapi.jar read tmr:///dev/ttyS0 --ant 1

November 30, 2018 2

You might also like