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?
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityI'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?
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:
- Copy the JArduino folder (located in the distribution in
org.sintef.jarduino.samples/arduino
) into/libraries/
- Launch your Arduino environment
- File -> Examples -> JArduino -> JArduino firmware. It should open an Arduino program that you should upload to your board using the normal Arduino procedure.
- Your Arduino board is now ready for Jarduino. You can exit the Arduino environment forever and launch Eclipse. Just run the Java/JArduino program.