Doing Java development

Get a JDK:
  1. opkg update
  2. opkg install openjdk-6-jdk
Then you have all the familiar JRE and JDK tools, like java, javac, jar, etc.

If you are able to install, but there is a dependency error, try to install all of the individual packages:
  • opkg install openjdk-6-common
  • opkg install openjdk-6-java
  • opkg install openjdk-6-jre
  • opkg install openjdk-6-jdk
  • opkg install openjdk-6-vm-zero

It might be that your particular distribution don't have those packages in the package list. In that case:

URLs in required installation order:


 Download the newest version for armv7a (or all) architecture, example:

  •  librhino-java_1.7r2-r0_all.ipk
  • openjdk-6-common_6b24-1.11.1+1.11.2-devel+hg1+54ceda20a02c-r17.0_armv7a.ipk
  • openjdk-6-java_6b24-1.11.1+1.11.2-devel+hg1+54ceda20a02c-r17.0_armv7a.ipk
  • openjdk-6-jdk_6b24-1.11.1+1.11.2-devel+hg1+54ceda20a02c-r17.0_armv7a.ipk
  • openjdk-6-jre_6b24-1.11.1+1.11.2-devel+hg1+54ceda20a02c-r17.0_armv7a.ipk
  • openjdk-6-vm-zero_6b24-1.11.1+1.11.2-devel+hg1+54ceda20a02c-r17.0_armv7a.ipk

Install using: opkg install <filename>


root@beaglebone:/usr/src/javatest# cat

class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello World!"); // Display the string.



root@beaglebone:/usr/src/javatest# javac

root@beaglebone:/usr/src/javatest# java HelloWorld

Hello World!



Eclipse IDE

If you want to use Eclipse on your PC to do development, one way to do that is to use the Eclipse Remote System Explorer.

Project setup, editing and building

If it is not already installed on your Eclipse, you can get it under "Install new software" and searching for "Remote System Explorer" and "Remote System User Actions".
When Remote System Explorer is install, open the Remote System Explorer Perspective.
In the tab "Remote System Details", right click, and select "New" -> "Connection"
Type in the hostname / IP address of your BeagleBone. Use SSH for all settings.

Create a folder where you want to have the project files, e.g. "My Home/dev/myproject"

On that folder, right-click and select "Create Remote Project":

Switch back to Java perspective to see the new project.
On the project, right-click and select properties
Under "Project Facets", click the "Convert to faceted form.." link:

Select the Java Facet, and the appropriate version (e.g. 1.6):

You can now start adding classes and building the project like a normal Java project. The source will sit on the remote system, the local computer will do the build, and the output is stored back to the device (defaults to build/classes under your project directory).

Remote debugging

Start the program on the device, either directly in a terminal window, or through the "Remote system explorer". Add the following parameters to listen for a remote debugger:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 -cp build/classes net.cameon.automation.control.Control

 As we have here set the "suspend=y", the program will wait for the debugger to attach before starting to run.

Inside Eclipse, right click on the class to debug, and select "Debug as " -> "Debug Configurations...".
Select "Remote Java Application", and type in the IP and port of the remote device. The port is the same as we set on the command line previously:

Click Debug to start debugging.

Accessing Serial ports from Java

One way to access the serial ports from Java on the BeagleBone, is to use the RxTx library. Install both the native part and the Java glue library:

opkg install rxtx
opkg install librxtx-java

Then you can program using RxTx on the BeagleBone as you would on any other system.

and then run the program with a command that specified both the path to the rxtx.jar and the serial native library (.so) files:

java -Djava.library.path=/usr/lib/jni/ -cp .:/usr/share/java/rxtx.jar CommTest

The built-in serial ports on the BeagleBone isn't autmatically detected by RxTx. To add them to the list of available ports, set the "" property to a colon-separated list of port names. You can do that in a property file, or directly on the command line:

java -Djava.library.path=/usr/lib/jni/ -cp .:/usr/share/java/rxtx.jar CommTest