The Raspberry Pi is not a very powerful device, however as it is so flexible, it is a very useful machine to have to test programs on. However actually programming and building your programs on the Pi itself would be far too time-consuming to make the testing worthwhile.
NetBeans solves this problem with ease by allowing you to program and build your projects on your usual machine (likely a lot more powerful than the Pi!) and then send and run the built project on the Pi. Programs such as PuTTy aren’t necessary as NetBeans does all the work for you – that means no SSH setup required! Your program then runs on the Pi as you would expect but with the added bonus of all outputs and debugging information being sent back to your machine where it is displayed in the normal Output window.
I’m now going to show you how to do this by deploying our Java PDF Library SDK to the Pi.
Requirements:
- – NetBeans 8.0 or greater.
- – Raspberry Pi running Java 1.8.0 (with JavaFX installed)
- – Both the development machine and the Pi need to be connected to the Internet (I connected them both to them same network)
- – A NetBeans project that you want to deploy to the Pi
Steps:
- Setup the connection between the Pi:
- – Open the Project Properties window of the project you want to deploy
- – Select the Run tab, click Manage Platforms then Add Platform
- – We then select Remote Standard Java Edition and proceed to fill out the form
- – I’m going to give it a Platform Name of “Pi Config”
- – The Host field is for the IP address of the Pi
- – The default Username is “pi” and the Password “raspberry”, but if you have changed the login options on the Pi, then you will need to change those here as well
- – The Remote JRE Path for our Pi was: “/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java”, but it might well be different on yours. Once all the boxes are filled in, click finish to complete the setup. If NetBeans says it can’t connect to the host, then verify that all the fields contain the correct information
- – NetBeans will now ask you for a name for the Runtime Platform. Call it Remote Pi.
- 2. You should now be taken back to the Run tab of Project Properties where we are now going to finish the configuration of the project:
- – Make sure the Runtime Platform is “Remote Pi”
- TIP: If you ever want to run the project on your local machine rather than the Pi, just change the Runtime Platform to the default via the drop-down menu
- – I have added an argument so the PDF viewer opens a PDF file automatically, however your project may not need this.
- – Make sure the Runtime Platform is “Remote Pi”
Thats it for the configuration of the project. Now we just need to run the program!
To do this, firstly make sure the Pi hasn’t been booted to the desktop. If you are on the desktop, logging out should return you to the correct command line. Now all you need to do is hit Run in NetBeans and your project should magically appear on the Pi!
I hope you’ve enjoyed our article, please let us know in the comments below.