I'm interested is it possible to compile Java code to native code so that I can run it on some cheap board like Arduino or Raspberry pi?

What compiler can you recommend?

  • 1
    Yes you can run java on the Raspberry Pi. It is like any other Linux computer that way. I don't know of any Java support for the arduino. Commented Jan 4, 2016 at 16:03
  • 1
    There are two JDKs available I'm aware of, Oracle 8 for ARM, and the open source Iced Tea that's in the Raspbian repos.
    – goldilocks
    Commented Jan 4, 2016 at 16:32
  • @SteveRobillard - There is JArduino which might fit the bill. Commented Jan 5, 2016 at 16:16
  • 1
    @Greenonline thanks, note I did say I didn't know of any but I do now. Commented Jan 5, 2016 at 16:20

2 Answers 2


Yes, you can compile java code to native for example using gcj and run it on Raspberry Pi. But you can also run a complete java stack on the pi, no problem.


On the Arduino, you could take a look at JArduino library, take a look at this answer to Control an Arduino with Java. It provides a Blink example written in Java.

You will need to update the Arduino firmware first though:

Before using JArduino, please make sure your Arduino board contains the JArduino firmware:

  1. Copy the JArduino folder (located in the distribution in org.sintef.jarduino.samples/arduino) into /libraries/
  2. Launch your Arduino environment
  3. File -> Examples -> JArduino -> JArduino firmware. It should open an Arduino program that you should upload to your board using the normal Arduino procedure.
  4. Your Arduino board is now ready for Jarduino. You can exit the Arduino environment forever and launch Eclipse. Just run the Java/JArduino program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.