Serial Communication with Palm OS - Part 3/4
On Ubuntu 18.04 and Java
24.11.2019
After having a Palm-OS-Application which is able to send some data via the serial interface and reading them from a commandline on Ubuntu 18.04, it would be also nice to have a - maybe - better environment to take control of. One way, which I want to describe here, is to read process the data in Java.
For this part, thre components are needed:
- A Java-Environment
- The eclipse IDE
- A suitable library for reading from/writing on the serial interface
For the frist two "components" are a lot of tutorials and how-tos avaialbe like these:
How To Install Java with `apt` on Ubuntu 18.04 (FYI: the "JDK" - Java Development Kit - is needed.) How To Install Eclipse Oxygen IDE On Ubuntu 16.04 | 17.10 | 18.04 (FYI: This site also explaines how to install a JDK.)For the last "component" are two libraries available:
Of course there are more libaries available, like "java-simple-serial-connector", but in my case "RXTX" worked best with Ubuntu 18.04 and "jSerialComm" worked best with Windows XP.
RXTX installation - Part 1/2 - shared object
Just install the rxtx-package via apt:
sudo apt-get install librxtx-java
This install some .so-files which must be recognized by Java. These files get installed in:
/usr/lib/jni/
Because only the serial interface is used in this case, there is only one file, which is needed:
/usr/lib/jni/librxtxSerial-2.2pre1.so
This is the current version (23.11.2019), maybe it is another version in the future.
This file needs to be copied into the JDK/lib/i386/-folder. In order to get the correct "JDK"-path, just run:
whereis java
and the output should look like this:
java: /usr/bin/java /usr/share/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz
In this case "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" or "/usr/lib/jvm/java-11-openjdk-amd64/" is the correct path. So the correct copy-command looks like this:
sudo cp /usr/lib/jni/librxtxSerial-2.2pre1.so /usr/lib/jvm/java-11-openjdk-amd64/lib/i386/librxtxSerial.so
RXTX installation - Part 2/2 - Java Archive
The "/usr/share/java"-folder should contain the "RXTXcomm-2.2pre2.jar", otherwise search for "RXTXcomm*.jar" to get the correct location:
sudo find / -name "RXTXcomm*.jar"
After knowing the correct location, the RXTXcomm*.jar needs a link in Eclipse:
- Click on the project and hit "Alt+Enter" to open the properties for the project
- Select "Java Build Path" in the menue.
- Select the "Libraries"-Tab.
- Select "Modulepath"
- Add the RXTXcomm*.jar via the "Add External JARs..."-button.
The Java-Application
Now, everyhting is set up, in order to create the application. There are some examples out there to create a small programm, which let you read from the serial interface. The following example is very simple:
The source-code is based on this example.
After the programm gets executed and some data was sent from the related Palm OS Application, which was created here, it should look like this:
The last part (4/4) describes, how the data from the application can be read with Java on Windows XP:
Serial Communication with Palm OS on Windows XP and Java