Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Really basic concept question...

Thu Dec 10, 2015 4:50 pm

I will apologize in advance, I have been doing a lot of reading on this site (but not enough for sure). I am going to buy a RP2 shortly and "toys" to attach to it (sensor board etc.). I have no specific project in mind yet, but I am sure something will come to mind. I enjoy programming, and have recently finished a couple of java courses, so I became somewhat comfortable using the Netbeans development package and have it already installed on my macbook.

My question is, can I develop my programs on the macbook, and compile , then load the executable to the SD card? Are there 'libraries' I need to install in order to read and write to the physical I/O on the RPi?

sorry for the basic question, I have found quite a bit about starting up the boards and basic configuration, but I just have not found the doc/ thread that speaks of developing an actual user program and compiling.

Thank you for any insight or direction

Tom

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Really basic concept question...

Fri Dec 11, 2015 12:03 am

Hi Tominboston,

You might be interested in getting a copy of Stephen Chin and James Weaver's new book: Raspberry Pi with Java:
Programming the Internet of Things (IoT)
(http://www.amazon.com/exec/obidos/ASIN/ ... homeaut-20)

I have written up a detailed review/article on my blog:
http://www.savagehomeautomation.com/rpijp


This book will help guide you through getting started with Java on the Raspberry Pi.

To answer your questions ...
"can I develop my programs on the macbook, and compile , then load the executable to the SD card?"
Yes. You can do all your development work in an IDE and then transfer your compiled programs via the network (SSH/SCP/FTP) to make things easier. Netbeans includes features to configure the Raspberry Pi as a remote platform and its can transfer the program for you automatically when you launch your application.
"Are there 'libraries' I need to install in order to read and write to the physical I/O on the RPi?"
Yes. The two leading libraries for accessing GPIO, PWM, SPI, I2C, and SERIAL (UART) are The Pi4J project (http://www.pi4j.com) and the OpenJDK Device I/O project (http://openjdk.java.net/projects/dio/). The book I mentioned includes details on both libraries and example code using each.

Personally, I would suggest starting with Pi4J. But please note that my opinion is completely and utterly biased since I founded the Pi4J project :-)

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Re: Really basic concept question...

Fri Dec 11, 2015 2:14 pm

Robert , thank you very much for all that information ! I will take your suggestions and get the book and also start with your libraries. I ordered a "deluxe " Raspberry Pi 2 B kit the other day that will have SD card, sensors, push-buttons etc all included so it will be a fun winter project to play with. I want to use java as I am familiar with it and I have a bunch of programs written using some Swing graphics etc. So I would like to add some real life I/O to them and think of something useful for project. I travel a bit so being able to do some programming without being connected the board is good for me.

Thank you again for the help!

Tom

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Really basic concept question...

Fri Dec 11, 2015 5:39 pm

Hi Tom,

You may find a few Pi + Java articles on my blog interesting/helpful:
http://www.savagehomeautomation.com/pi-slices/

If you are looking for an easy project to get started with GPIO, then this type of project is pretty simple/basic:
http://www.savagehomeautomation.com/pro ... ights.html

Its about controlling power to Christmas lights, but of course you could control power to anything.

Lastly, the PiBrella device is a nice simple plugin board that make it simple to test button inputs and LED outputs as well as other functionality:
http://www.savagehomeautomation.com/pro ... rella.html


Good Luck and Have Fun!
Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Re: Really basic concept question...

Sun Dec 13, 2015 10:44 pm

Thank you again Robert those may be timely projects.:)

One thing I am still a bit confused on, ( and the book you recommended is enroute to me now), is adding the classes/ libraries to netbeans to be able to generate an executable that I can copy to the pi sd card. I found lots of info on setting it up to automatically load over my network but I wanted something a bit simpler. I guess I could just do it all connected to the pi but thought it would be more flexible while traveling if I could bang out some code with no pi connected.

Maybe the book will talk about it.

Thank you again,

Tom

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Really basic concept question...

Sun Dec 13, 2015 11:25 pm

You certainly are not required to have the Pi connected on the network to work on your Java code. You can compile your JAR file(s) independently whenever you need. Only when you are ready to deploy them to the Pi hardware do you need the Pi connected or you could manually copy them to the SD card if you don't have a live network connection. For that matter you could also copy them to a USB stick to transfer.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Re: Really basic concept question...

Fri Dec 18, 2015 3:50 pm

Well I just got back from a trip and found my copy of Raspberry Pi with Java arrived. I have only skimmed it for about 20 min so far but it has really enlightened me and answered all of the questions I still had. I am expecting my Pi to arrive next week, just in time to play over the holiday break.
:P

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Really basic concept question...

Fri Dec 18, 2015 4:31 pm

Glad to hear it is helping! Once you have finished the book you may want to add a review on Amazon to help guide other perspective buyers :-) Its a recently published book so there are not many reviews in yet.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Return to “Java”