Compatability

We’re still using this in 2023 with NetBeans IDE 11.0 with no problems.

See here for the netbeans 11 setup.

Enabling Running Remote Projects in NetBeans As Root User

By default the root account is disabled in Raspbian, but for an application to access the IO pins it needs root user privileges.  There are ways to configure the IO to get around this but its not all that easy and for development its often just easier to have full root access so the permissions don’t get in your way (you can disable it later before releasing your RPi into the wild if the security issue is a concern).  When running from the command line you can do this simply using the sudo command, but when remotely running from NetBeans you need a way for it to be able to run the application as root user if you are using the IO pins.  There doesn’t seem to be a configuration option in NetBeans for this currently so enabling the root user account and letting NetBeans use it is a simple work around. Use this command:


sudo passwd root

Now you can log into your pi as the root user so give NetBeans the username ‘root’ and the password you set.

Now check the ssh config


sudo nano /etc/ssh/sshd_config

Search for PermitRootLogin and change it to yes (the default “prohibit-password” or “without-password” won’t work – change it to “yes”). Remove the # at the start of the line if present.

Use CTRL+X to exit and then reboot.

To undo logging in as root later, use this command


sudo passwd -l root

​Creating a NetBeans project from an existing project

See our other page here.

​Creating A New NetBeans Project

Menu > File > New Project > Select ‘C/C++ Application’

Set the projects name and location

Select C or C++ from the drop down

Leave the default options for ‘Build host’ and ‘Tool collection’.

Click ‘Finish’

Select the ‘Services’ tab in the left window.

Ensure the Raspberry Pi is powered up and connected to the network.

Right click ‘C/C++ Build Hosts’ > Add New Host

Enter the IP address of the Raspberry Pi

Press Next > Enter the login user name (‘pi’ (or ‘root’ – see above))

Press next and NetBeans will attempt to connect and then prompt for the password.

Press Finish

Select the ‘Projects’ tab in the left window.

Right click the projects name > Properties

Build > Build Host > Select the build host name you just created.

Run > Console Type > Standard Output

Apply and Close

If you are using the bcm2835 library for the IO pins etc, ensure you’ve installed it by following the guide here, add the bcm2835.h file to your project and do this:

Right click the project > Properties > Build > Linker > In the ‘Libraries’ section press the ‘…’ button > Add Option… > Other Option > Enter: -lbcm2835

Right click the project > Build

Change of IP Address

You can’t assign a new IP address to an existing build host.  You have to re-create.

Select the ‘Services’ tab in the left window.  Under ‘C/C++ Build Hosts’ right click the old pi@ build host > Remove Host

Then follow the steps above in ‘​Creating A New Project’.

Troubleshooting Remote Host Connections

Manual RPi Network settings?

Do you have the RPi configured with manual network settings (IP address, subnet etc)? If so make sure they are correct and in particular the gateway IP address – we’ve found if the gateway is wrong / invalid on the RPi NetBeans will hang before prompting for the password when adding a new connection and be unable to connect for existing connections (even though SSH connections work fine using another SSH client).  A quick fix is to set it to use DHCP and see if NetBeans can connect correctly then.

1 network path

Ensure your PC doesn’t have 2 network paths to the RPi.  For example if you have both WiFi and Ethernet connected and both are on the same subnet this has caused NetBEANS to hang for us after entering the username and waiting for the password prompt.

Can you connect at all

If the network connection good – can you SSH into the RPi using the same login from a SSH client OK?

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. Marco Sartore

    3 years ago

    As an update to my earlier message: I answered myself to the question. The point is that every Project’s setting (as explained in the Tutorial), once set, is not stored for both compilation modalities. You must re-type the Project’s options in the Release mode as they are in Debug mode, and then everything works just fine.
    Bye

  2. Marco Sartore

    3 years ago

    Hi,
    many thanks for this beautiful tutorial. I have a suggestion and a question.

    My suggestion is to add a detail to the tutorial: I was unable to share files with my RaspberryPi not for connection problems, but for an option to select, which is worth to be mentioned in the tutorial. The option is: tab “Service” > C/C++ Build Hosts > double click root@ip_address and in the Host properties panle opening therefter select “Access project files via” and set it to SFTP.

    My question is: I succeeded to compile and execute in debug mode but not in run mode. I get the error: “/usr/bin/ld: cannot find -lbcm2835”. How to fix the problem ?

    Many thanks,
    Marco

  3. priyanka deshmukh

    6 years ago

    this is a good tutorial.. i follow this website tutorials quite a lot of times.. keep it up!!

  4. priyanka deshmukh

    6 years ago

    Hello i get a problem here..
    NetBeans will
    hang before prompting for the password when adding a new connection. it keeps saying connecting to root@ipaddress….. (even though SSH
    connections work fine using another SSH client such as PUTTY).
    just a day before it was working but now it hangs. I need help as i have only a ip address to connect with and not sure about how to use the dhcp.

    1. Currywurst

      3 years ago

      same problem here, but it was never working for me.

  5. Javier Nadal

    7 years ago

    Thanks for the info! Quick question, are the files only stored in the Raspi? Or are the main files on the PC as well? Just concerned that if the SD goes I’d loose everything. Can we combine this with version control? Thanks.

    1. Adam

      7 years ago

      The RPi gets a copy, the files are stored on your PC

  6. Michael D. Moradzadeh

    7 years ago

    This is a great tutorial and I was easily to set up, compile simple code, and run it on the remote pi.
    HOWEVER, my challenge now is to compile and run a project imported from github. I get either a “no executable found” or a “file not found” referencing the first include. Can you point to a resource that helps clarify how to hook in a modestly complex external set of files?

  7. Tur Tur der Scheinriese

    8 years ago

    Hi,
    thanks for the great tutorial.
    Im getting an error when trying to compile:

    make: Makefile: No such file or directory
    make: *** No rule to make target ‘Makefile’. Stop.

    How can i solve this?

    1. Guy

      7 years ago

      Have you manage to solve this ? i have the same issue

    2. Siegfried Störenfried

      3 years ago

      Creating a new project by right click on the host –> create new project … fixed the above mentioned problem for me.

  8. zoli meder

    8 years ago

    I have a simple code which deal with /sys/class files and at some point I need root privileges. Can someone help me how to make root priveleges from the program? maybe some code or some commands for the compiler? I am using eclipse and g++. I make remote compile.

  9. Sol Badguy

    8 years ago

    1 question
    my project needs to have openCV library
    Does Netbeans need it, too? Or openCV on the Pi2 is enough?

    1. Adam

      8 years ago

      Compiling happens on the RPi, so only the RPi needs the libraries used

  10. Leopold Bielawski

    8 years ago

    When I copied wiringPi.h header from /usr/local/include to /usr/include then is all ok. The file will be found there.This is very strange for me.

  11. Leopold Bielawski

    8 years ago

    I’ve allready successfully created a raspi project in NetBeans, but my problem is, that it cannot find header file which are remotely located in folder /usr/local/include at all. I can see the header files in Terminal (at the bottom in NetBeans), but not if I write #include statement. Header files which are located in /usr/include can be included.If I move the mouse pointer on this file and hold the Strg I see that /usr/local/include will be show as analysed path. Also in Code Assistance the folde /usr/local/bin is included. I hope, someone can help me.

  12. Andreas Sumerauer

    9 years ago

    if you are troubled by a changing Raspi IP address you might want to install samba on the raspi. This will allow to use the host name (e.g. raspberrypi) instead of the ip address. (+ you can store the project files on the raspi itself)

    1. Adam

      9 years ago

      Works fine for us. If you are having problems check your steps or try one of the many forums to find the problem

  13. Nicolas

    9 years ago

    Having problems.

    Error copying project files to /home/pi/.netbeans/remote/192.168.0.28/niko-Windows-x86_64 at [email protected]:

    Can not check remote directories. xargs exited with error code 123

Leave a Reply to Marco Sartore Cancel reply

Your email address will not be published. Required fields are marked *