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

Compile Mercury API on Raspberry Pi

This document provides steps to compile a Java API on a Raspberry Pi. It involves installing Java if not already present, downloading the Mercury API SDK from ThingMagic's website, extracting and editing sample Java files, compiling the files while specifying classpaths and library dependencies, and potentially recompiling Linux libraries if errors occur regarding missing libraries. The steps also include extracting jar files and copying necessary files to the proper locations.

Uploaded by

Wallace Muniz
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)
60 views2 pages

Compile Mercury API on Raspberry Pi

This document provides steps to compile a Java API on a Raspberry Pi. It involves installing Java if not already present, downloading the Mercury API SDK from ThingMagic's website, extracting and editing sample Java files, compiling the files while specifying classpaths and library dependencies, and potentially recompiling Linux libraries if errors occur regarding missing libraries. The steps also include extracting jar files and copying necessary files to the proper locations.

Uploaded by

Wallace Muniz
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

Compile JAVA API on Raspberry Pi

Ensure you have Java in your Pi, if you do not have please follow below steps:

Steps to Install Java:

[Link] latest version of java from oracle website.


[Link] copy downloaded file into Raspberry Pi.
[Link] the file .
cmd :tar xvf <location to the file>
example :
tar xvf [Link]

[Link] add java installed location /etc/profile file like 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

[Link] check java installed or not with below commands


cmd: which java, java -version, java , javac

Steps to Compile Java API on Pi:

1) Download the latest mercuryapi available from the ThingMagic website using the below link:
[Link]

2) Copy Mercury API SDK to Raspberry Pi and extract the API SDK using unzip command(as
shown in below example).
sudo unzip [Link] -d ./mercuryapi-[Link]

3) Go to “java/samples_nb/src/samples” folder and edit the sample java application


(example:[Link]), comment out the line “PACKAGES=samples;”(line number 7) and save the
file.
If you are unable to access mercury API, then change permissions using below command:
sudo chmod -R 777 mercuryapi-[Link]

4) Copy [Link] to Java folder using below command(you can use the below command when
you are in folder “java/samples_nb/src/samples”)
cp [Link] ../../../
5) Go to Java folder and compile the application using the following command.
javac -cp .:[Link]:[Link] <[Link]>
Example: sudo javac -cp .:[Link]:[Link] [Link]

6) The general error you could see if when Java complains about missing [Link]. When
Java complains about missing [Link], it can't find the required libraries for using the serial
ports on your system. Here is how to recompile them:

• First in the C folder of the mercury API there is a folder:


c/proj/jni
That has the Makefile for compiling the proper lib driver. Go to “c/proj/jni” folder.
• Next find the jni.h file on your system(using below command):
$ sudo find / -name "jni.h"
You will get the result for “find” command as below
/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/include/jni.h
add that directory to the [Link] 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)
Save and quit
• Then run “make -f [Link]”. The result will be [Link].0, which
you rename to [Link](using below command)
“mv [Link].0 [Link]”
• Now traverse back to mercuryapiX.X.X/java
• Extract the [Link] file using command “jar xf [Link]” or use the
instructions available at
[Link]

• Now you will have a folder named “com” in the current(java) folder.
• Copy the [Link] file from the java directory into com/thingmagic(using below
command).
cp [Link] ./com/thingmagic/
• Copy the [Link] file you created before into java/com/thingmagic (there are a few
other .lib files there).
7) Run the application using following command.
sudo java -cp .:[Link]:[Link] <sampleapplication> <comport> <--ant
1,2>
Example: sudo java -cp .:[Link]:[Link] read tmr:///dev/ttyACM0 --ant 1

You might also like