Building Applications Like It’s 1996

I hate the modern Java build systems. Loathe and despise. My attempts at playing along this time have not fared any better than any previous time, so I, again, find myself burning the world to the ground and going back decades. Life was simpler then. It could be simpler now! Anyway. Compare these instructions with the frantic activity and downloads done by gradle and friends. Or don’t, I don’t mind.

For starters, the purejavacomm library is not packaged with Debian, but rxtx is. We’ll use that and replace the imports (they’re drop-in compatible):

apt-get install librxtx-java

IOIODude

Let’s build this first as it’s simplest:

> pushd software/IOIODude
>   sed -i -e s/purejavacomm/gnu.io/ src/main/java/ioio/dude/SerialPortIOIOConnection.java
>   javac \
>     -cp /usr/share/java/RXTXcomm.jar:src/main/java \
>     src/main/java/ioio/dude/SerialPortIOIOConnection.java \
>     src/main/java/ioio/dude/IOIODudeMain.java
>   pushd src/main/java
>     jar cf IOIODude.jar `find . -name '*.class' -print`
>   popd
>   mv ./src/main/java/IOIODude.jar .
>   find . -name \*.class -exec rm {} \+
>   chmod +x ioiodude
> popd

IOIOLibCore

Equally simple:

> pushd software/IOIOLibCore
>   javac -Xlint:none -cp /usr/share/java/RXTXcomm.jar:src/main/java `find .  -name \*.java`
>   pushd src/main/java
>     jar cf IOIOLibCore.jar `find . -name '*.class' -print`
>   popd
>   mv ./src/main/java/IOIOLibCore.jar .
>   find . -name \*.class -exec rm {} \+
> popd

IOIOLibPC

Same deal:

> pushd software/IOIOLibPC
>   sed -i -e s/purejavacomm/gnu.io/ src/main/java/ioio/lib/pc/SerialPortIOIOConnection.java
>   sed -i -e s/purejavacomm/gnu.io/ src/main/java/ioio/lib/pc/SerialPortIOIOConnectionBootstrap.java
>
>   javac -Xlint:none \
>     -cp /usr/share/java/RXTXcomm.jar:../IOIOLibCore/IOIOLibCore.jar:src/main/java \
>     `find .  -name \*.java`
>   pushd src/main/java
>     jar cf IOIOLibPC.jar `find . -name '*.class' -print`
>   popd
>   mv ./src/main/java/IOIOLibPC.jar .
>   find . -name \*.class -exec rm {} \+
> popd

HelloIOIOConsole

Compile and run. That classpath is getting absurd.

> pushd software/applications/pc/HelloIOIOConsole
>   javac \
>     -cp ../../../IOIOLibPC/IOIOLibPC.jar:../../../IOIOLibCore/IOIOLibCore.jar \
>     src/main/java/ioio/examples/hello_console/HelloIOIOConsole.java
>
>   java \
>     -cp ../../../IOIOLibPC/IOIOLibPC.jar:../../../IOIOLibCore/IOIOLibCore.jar:src/main/java:/usr/share/java/RXTXcomm.jar \
>     ioio/examples/hello_console/HelloIOIOConsole
> popd

Using Bluetooth From The Command Line

bluetoothctl will cheerfully pair with the adapter, just remember to set agent on first or it won’t prompt you for a password. (I hate software.)

Make a rfcomm device with

mknod -m 666 /dev/rfcomm0 c 216 0

Then attach to it, using the IOIO’s BT address:

rfcomm bind /dev/rfcomm0 00:0C:41:E1:D1:40

Then run your IOIOlib application:

java -cp $CLASSPATH -Dioio.SerialPorts=/dev/rfcomm0 $MAINCLASS

When you’re done, use:

rfcomm unbind /dev/rfcomm0