Let there be Netbeans…
To develop on the Revolution or the Raspberry Pi itself is extremely laborious. For the use of a modern development environment, the Pi lacks a little bit of power. It makes more sense to develop on the PC and run the software on the RevPi, if possible without manual interaction.
After a short research, my choice fell on Netbeans. Netbeans brings everything I need: an extensive editor, remote host support, etc. Eclipse probably brings similar features. But I am used to Netbeans.
Netbeans was given to the Apache Foundation by Oracle a few years ago. The transition of the code to Apache is being done piecemeal and does not seem to have been completed yet. Initially, it made working with Netbeans very difficult. But true fans remain loyal to their software. Meanwhile, Netbeans almost shines again in its old glory. Two times, however, manual action was required to get Netbeans running as desired.
Installation
First of all I downloaded the current Netbeans Version 11.3 and the current Java SE Development Kit 14. Now I installed the JDK.
Here comes the first tripping point. When you try to install Netbeans, an error message is displayed
After a short research on the net it is clear that the installer is not compatible with the current JDK version 14. Here is a post on Stack Overflow on this topic: How to fix Netbeans IDE installation error? The solution: install an older version of the JDK.
Now I could have simply downloaded an older JDK version. For that, I would have had to register with Oracle, which I did not feel like doing. I decided to take the harder path and used openJDK 13.
The easiest way seems to be to overwrite the existing JDK installation with the old version. This can be found under C:\Program Files\Jave\jdk-14.0.1. First I made a copy of jdk-14.0.1 in jdk-14.0.1_copy in the same directory. Now I unpacked openjdk-13.0.2_windows-x64_bin.zip. The ZIP file contains a directory “jdk-13.0.2”. I copied the content of this directory into C:\Program Files\Jave\jdk-14.0.1 and overwrote all existing files. Now the Netbeans installation worked. In contrast to a post on stack overflow, you should not switch back to JDK 14 yet. The plugin manager of Netbeans does not seem to be able to cope with that either.
To develop in Netbeans for C/C++, an appropriate plugin must be installed. Here comes the second point where the change from Oracle to Apache becomes noticeable. There is no official C/C++ plugin for Netbeans 11 yet, but the plugin for Netbeans 8 works fine. I have activated the NetBeans 8.2 Plugin Portal in Tools > Plugins > Settings.
In the tab Available Plugins, the list of plugins must now be updated via Check for Newest. Now the plugin C/C++ appears in the list. I have installed it.
You can probably switch back to the JDK 14 now. But I haven’t tried that.
Setting Up the Build Host
Via Menu > File > New Project > Select ‘C/C++ Application I have created a new project.
Via “Menu > File > New Project > Select ‘C/C++ Application” I have created a new project. I have assigned the creative project name “RevPiHello”. Now Netbeans may complain that no build environment is installed. But it doesn’t matter, we want to work with Revolution Pi.
To compile and execute programs on the RevPi, a build host must be set up. In the default setting of Netbeans you will find a tab “Service” on the left side. If you select the “C/C++ Build Host” with the right mouse button, you can add a new build host.
At Host-Name the IP address of the RevPi must be entered and on the following page pi as the Login name.
On the next page, the password must be entered (sticker on the side of the device) and with Finish the setup of the build host is completed.
Now the building host must still be set in the current project. This is done by right-clicking on the project (RevPiHello) and selecting Properties > Build. By default, two configurations Release and Debug are created. The settings for the Build Host should be made accordingly for both. Select pi@<IP address> on the right-hand side of the uppermost entry Build Host.
Now switch to Run > Console Type and select Standard Output.
By the way, if you create a new C/C++ project, you can also choose RevPi directly as build host. I noticed that afterward.
The First Project
I have already created a project. Now I have extended the empty example program in main.cpp by a few lines. Here you can download the whole project.
#include <cstdlib> #include <cstdio> using namespace std; int main(int argc, char** argv) { printf("Hello Revolution Pi\n"); return 0; }
In Netbeans the hammer icon is used to build the project. If it’s successful, does it look like this in something…
If you connect via SSH, you will find the executable file somewhat hidden under ~/.netbeans/remote/<IP address RevPi>/<PC name>/<Path on PC>/NetBeansProjects/RevPiHello/dist/Debug/GNU-Linux. I have found no way to change this path except by mounting fixed-shard folders. A tutorial can be found e.g. here. I haven’t tried it, so without a guarantee.
If you run the program with ./revpihello you will get the following output. So everything seems to have worked.
Alternatively, you can run the program directly in Netbeans by clicking the green arrow icon to the right of the two hammer icons. Netbeans shows you a terminal below.
I have now experimented a little bit and stumbled over a small unpleasantness, which made me doubt my abilities a little bit. If you run the program directly via Netbeans, via Run Project (green arrow), change something in the source code while the program is running, and perform Run Project again shortly after the program has finished, it may happen that the executable file is not changed. I suspect that a process has not yet released the file in time. Interestingly, the build process seems to finish properly. At least I do not get any error messages. A Run Project is useless because Netbeans thinks that the state on the RevPi is up to date and does not trigger a new build process, but simply runs the program.
Ideally, always wait a few seconds shortly after the program has finished. Worked reliably for me. Alternatively, you can run “Build Project” manually.
I am developing Raspberry projects for some years with Visual Studio. I am very satisfied with it and it also should work with revolutionpi. The installation is much simpler. Just download and install the Linux environment and it works via SSH.
Regards, Wolfram
Hello Wolfram,
I used Netbeans because I have been working with it for many years and I am used to it.
used to it. Of course you can use Visual Studio just as well.
Since Netbeans was handed over by Oracle to the Apache Foundation a few years ago, there have been problems from time to time, especially in the early days, which is probably caused by some licensing issues during the handover, among other things. Apparently, while writing the article, I just caught a time when the problems accumulated.
I haven’t done much development lately, but at least I haven’t run into any major problems.