ION GETTING STARTED WITH JAVA
- Ion Technical Information Manual
40
9
ION GETTING STARTED WITH JAVA
Introduction
This quick guide will explain how to start developing in Java with your CAEN RFID R4301P reader. It starts from the
assumption that you have already installed the Development Virtual Machine as described by the relevant chapter and
that you will use it as the development platform
6
.
Setup the development environment
The first step in setting up the development environment is to install the JDK on the virtual machine, for this purpose
type the following commands on a shell window:
develop:~# aptitude update
develop:~# aptitude install default-jdk
Then, in order to use the SDK (Software Development Kits), you need to download the java libraries from our
Software
and Firmware web area
or at the
SDK (Software Development Kits)
,
SW/FW
section. The libraries (CAENRFIDLibrary.jar
and RXTXcomm.jar) are included into the SDK package, extract them from the SDK_4.0.0.zip file using the unzip
command from a shell window or using the archive manager (squeeze) from the GUI.
Testing the development environment
At this point you are able to compile and test the first, very simple, Java program:
public static void main(String[] args) {
import java.math.BigInteger;
import com.caen.RFIDLibrary.*;
class CAENTest {
CAENRFIDReader myReader = new CAENRFIDReader();
CAENRFIDReaderInfo myInfo;
CAENRFIDLogicalSource myLS;
CAENRFIDTag myTags[];
System.out.println("CAENTest starting...");
try {
myReader.Connect(CAENRFIDPort.CAENRFID_TCP, args[0]);
myInfo = myReader.GetReaderInfo();
String s = myInfo.GetModel();
System.out.println(s);
myLS = myReader.GetSources()[0];
myTags = myLS.InventoryTag();
if( myTags != null ) {
BigInteger bi = new BigInteger(myTags[0].GetId());
System.out.println(bi.toString(16));
} else {
System.out.println("No tags found!");
}
6
Commands on the Development Virtual Machine are marked by the suffix
develop:~#
, while commands on the Ion R4301P Reader shell are
marked by the suffix
root@ion:~#.