{"id":217,"date":"2013-03-17T15:06:11","date_gmt":"2013-03-17T14:06:11","guid":{"rendered":"http:\/\/jcoder.me\/blog\/?p=217"},"modified":"2013-03-17T15:06:11","modified_gmt":"2013-03-17T14:06:11","slug":"more-raspberry-pi-awesomeness-gpio-java","status":"publish","type":"post","link":"https:\/\/jcoder.me\/blog\/2013\/03\/17\/more-raspberry-pi-awesomeness-gpio-java\/","title":{"rendered":"More Raspberry Pi Awesomeness: GPIO &#038; Java"},"content":{"rendered":"<p>I&#8217;ve been playing with the GPIO capabilities of the Raspberry Pi before using Python, which comes with easy GPIO access for the Raspberry Pi.<\/p>\n<p><strong>Java 8 for ARM<\/strong><\/p>\n<p>As I&#8217;m yet not very familiar with Python I got excited when Oracle accounced Java 8 for the ARM platform, so I downloaded the <a href=\"http:\/\/jdk8.java.net\/fxarmpreview\/\" target=\"_blank\">JDK 8 (with JavaFX) for ARM Early Access<\/a> from the Oracle website, copied it to the RPi, compiled an example app on my PC and copied the JAR to the RPi &#8211; and it runs!<\/p>\n<p>Obviously it takes some time to start the application but it works as excepted; of course it was a very simple example and there are some limitations, especially when it comes to graphics output, but it&#8217;s a good start.<\/p>\n<p>There is even JavaFX support in the JDK 8 which will output to RPi&#8217;s HDMI\/Video output, but that&#8217;s a topic for another posting ;)<\/p>\n<p><strong>Java &amp; GPIO<\/strong><\/p>\n<p>There is no native support for the RPi&#8217;s GPIO pins in Java, but there are two Open Source projects to get it running anyway:<\/p>\n<ul>\n<li><span style=\"line-height: 14px;\"><a href=\"https:\/\/projects.drogon.net\/raspberry-pi\/wiringpi\/\" target=\"_blank\">WiringPi<\/a> &#8211; an easy-to-use C library to control the GPIO pins<\/span><\/li>\n<li><a href=\"http:\/\/pi4j.com\/\" target=\"_blank\">Pi4j<\/a> &#8211; a Java class library providing a bridge between native code and Java to access the GPIO pins<\/li>\n<\/ul>\n<p>As described on the WiringPi website you can get WiringPi via git, and then build it directly on the RPi.<\/p>\n<p>The Pi4j website has lots of examples on how to work with the code, and from a Java developer&#8217;s perspective it is pretty straight forward to use Pi4j.<\/p>\n<p>I&#8217;ve used some code directly from the Pi4j&#8217;s example pages, put an LED on a breadboard, connected two pins and when running the program the LED blinks! Great!<\/p>\n<p>So, if you are planing to access GPIO via Java you should definitely take a look at WiringPi and Pi4j.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been playing with the GPIO capabilities of the Raspberry Pi before using Python, which comes with easy GPIO access for the Raspberry Pi. Java 8 for ARM As I&#8217;m yet not very familiar with Python I got excited when &hellip; <a href=\"https:\/\/jcoder.me\/blog\/2013\/03\/17\/more-raspberry-pi-awesomeness-gpio-java\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":219,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,46],"tags":[48,12,56],"class_list":["post-217","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding","category-raspberry-pi","tag-gpio","tag-java","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":3,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions"}],"predecessor-version":[{"id":221,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions\/221"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/media\/219"}],"wp:attachment":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}