In this post I would like to show how to connect JAVA 8 and Arduino. My objective was being able to control some servos using Java, so for that it was necessary to use RXTX library. At first there was plenty of tutorials so it was easy, but it took me several hours to realize how to make it run properly. In conclusion here you are a basic how to with the main points
1) Installing JAVA 8
The first step is installing JAVA 8, for that is we will use the repositories.
Add the repository.
Update the local repository.
Install the package.
To set the default Java:
2) Installing JAVA RXTX
The library that enables JAVA to communicate with Arduino is RXTX . I had plenty of problems with that. For JAVA 8 the only one that worked was the JAVA RXTX 2.2 pre2. In order to install it just copy the files like this:
Take in account that my pc is a 64 bits OS. You should change your folder and the *.so compilation in base of your system.
3) JAVA basic program
You should include the file RXTXcomm.jar in your project as a library in order to make your project run. A simple code example that you could use is based on the Arduino web page example:
3) Arduino CODE
In order to interact with Arduino it is necessary to upload some code to the board using the IDE.
I am a Spanish telecommunication engineer.I like social robotics, computers and almost everything with wires. Right now, I am working as a Software Engineer. Furthermore I am always happy to be involved in challenging projects.