Java == Pi

There is a lot of support for Java on Raspberry Pi, Pi will come with Java SE 8 and you can easily use the native interface (because it’s linux and IO’s is mapped as files) but it is much simpler to use the Java ME or PI4J.

Java ME

I develop┬ámostly internet services in Java/JavaScript and I almost forgot about Java’s embedded platform.

There is actually a specific version provided by Oracle for Raspberry Pi which can be found here:

http://www.oracle.com/technetwork/java/embedded/javame/embed-me/downloads/java-embedded-java-me-download-2162242.html

When installed It is simple to use and gives you an easy access to all the I/O’s. It also provide a lot of great libraries to handle communications and other stuff.

PI4J

Currently the only version is snapshot, but it works really well.

  • Export & unexport GPIO pins
  • Configure GPIO pin direction
  • Configure GPIO pin edge detection
  • Control/write GPIO pin states
  • Pulse GPIO pin state
  • Read GPIO pin states
  • Listen for GPIO pin state changes (interrupt-based; not polling)
  • Automatically set GPIO states on program termination (GPIO shutdown)
  • Triggers for automation based on pin state changes
  • Send & receive data via RS232 serial communication
  • I2C Communication
  • SPI Communication
  • Extensible GPIO Provider interface to add GPIO capacity via expansion boards
  • Access system information and network information from the Raspberry Pi
  • Wrapper classes for direct access to WiringPi Library from Java

You can read more and download the library here:

http://pi4j.com/