{"id":1948,"date":"2015-05-28T09:56:40","date_gmt":"2015-05-28T09:56:40","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=1948"},"modified":"2023-12-11T14:21:33","modified_gmt":"2023-12-11T14:21:33","slug":"creating-a-new-project","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/compilers-and-ides\/netbeans-windows\/creating-a-new-project","title":{"rendered":".Creating A New Project"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Compatability<\/h4>\n\n\n\n<p>We&#8217;re still using this in 2023 with NetBeans IDE 11.0 with no problems.<\/p>\n\n\n\n<p><a href=\"\/pi\/programming-in-c\/compilers-and-ides\/netbeans-windows\/installing-netbeans-for-c-remote-development-on-a-raspberry-pi\" target=\"_blank\" rel=\"noreferrer noopener\">See here<\/a> for the netbeans 11 setup.<\/p>\n\n\n<h4>Enabling\u00a0Running Remote Projects in NetBeans\u00a0As Root User<\/h4>\n<p>By default the root account is disabled in Raspbian, but for an application to access the IO pins it needs root user privileges. \u00a0There 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&#8217;t get in your way (you can disable it later before releasing your RPi into the wild if the security issue is a concern). \u00a0When 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. \u00a0There doesn&#8217;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:<\/p>\n<pre><code>\nsudo passwd root\n<\/code><\/pre>\n<p>Now you can log into your pi as the root user so give NetBeans the username &#8216;root&#8217; and the password you set.<\/p>\n<p>Now check the ssh config<\/p>\n<pre><code>\nsudo nano \/etc\/ssh\/sshd_config\n<\/code><\/pre>\n<p>Search for PermitRootLogin and change it to yes (the default &#8220;prohibit-password&#8221; or &#8220;without-password&#8221; won&#8217;t work &#8211; change it to &#8220;yes&#8221;). Remove the # at the start of the line if present.<\/p>\n<p>Use CTRL+X to exit and then reboot.<\/p>\n<p>To undo logging in as root later,\u00a0use\u00a0this command<\/p>\n<pre><code>\nsudo passwd -l root\n<\/code><\/pre>\n<h4>\u200bCreating a NetBeans project from an existing project<\/h4>\n<p>See our <a href=\"\/pi\/programming-in-c\/compilers-and-ides\/netbeans-windows\/importing-an-existing-project\" target=\"_blank\" rel=\"noopener\">other page here<\/a>.<\/p>\n<h4>\u200bCreating A New NetBeans Project<\/h4>\n<p>Menu &gt; File &gt; New Project &gt;\u00a0Select &#8216;C\/C++ Application&#8217;<\/p>\n<p style=\"margin-left: 40px;\">Set the projects name and location<\/p>\n<p style=\"margin-left: 40px;\">Select C or C++ from the drop down<\/p>\n<p style=\"margin-left: 40px;\">Leave the default options for &#8216;Build host&#8217; and &#8216;Tool collection&#8217;.<\/p>\n<p style=\"margin-left: 40px;\">Click &#8216;Finish&#8217;<\/p>\n<p>Select the &#8216;Services&#8217; tab in the left window.<\/p>\n<p>Ensure the Raspberry Pi is powered up and connected to the network.<\/p>\n<p>Right click &#8216;C\/C++ Build Hosts&#8217; &gt; Add New Host<\/p>\n<p style=\"margin-left: 40px;\">Enter the IP address of the\u00a0Raspberry Pi<\/p>\n<p style=\"margin-left: 40px;\">Press Next &gt; Enter the login user name (&#8216;pi&#8217; (or &#8216;root&#8217; &#8211; see above))<\/p>\n<p style=\"margin-left: 40px;\">Press\u00a0next and NetBeans will attempt to connect and then prompt for the password.<\/p>\n<p style=\"margin-left: 40px;\">Press Finish<\/p>\n<p>Select the &#8216;Projects&#8217; tab in the left window.<\/p>\n<p>Right click the projects name &gt; Properties<\/p>\n<p style=\"margin-left: 40px;\">Build &gt; Build Host &gt; Select the build host name you just created.<\/p>\n<p style=\"margin-left: 40px;\">Run &gt; Console Type &gt; Standard Output<\/p>\n<p style=\"margin-left: 40px;\">Apply and Close<\/p>\n<p>If you are using the bcm2835 library for the IO pins etc, ensure you&#8217;ve installed it by following the guide <a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/c-libraries\/bcm2835-by-mike-mccauley\">here<\/a>, add the bcm2835.h file to your project and do this:<\/p>\n<p style=\"margin-left: 40px;\">Right click the project &gt; Properties &gt; Build &gt; Linker &gt; In the &#8216;Libraries&#8217; section press the &#8216;\u2026&#8217; button &gt; Add Option\u2026 &gt; Other Option &gt; Enter: -lbcm2835<\/p>\n<p>Right click the project &gt; Build<\/p>\n<h4>Change of IP Address<\/h4>\n<p>You can&#8217;t assign a new IP address to an existing build host. \u00a0You have to re-create.<\/p>\n<p>Select the &#8216;Services&#8217; tab in the left window. \u00a0Under &#8216;C\/C++ Build Hosts&#8217; right click the old pi@ build host &gt; Remove Host<\/p>\n<p>Then follow the steps above in &#8216;\u200bCreating A New Project&#8217;.<\/p>\n<h4>Troubleshooting Remote Host Connections<\/h4>\n<p>Manual RPi Network settings?<\/p>\n<p style=\"margin-left: 40px;\">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\u00a0IP address &#8211; we&#8217;ve found if the gateway is wrong \/ invalid on the RPi\u00a0NetBeans 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). \u00a0A quick fix is to set it to use DHCP and see if NetBeans can connect\u00a0correctly then.<\/p>\n<p>1 network path<\/p>\n<p style=\"margin-left: 40px;\">Ensure your PC doesn&#8217;t have 2 network paths to the RPi. \u00a0For example if you have both WiFi and Ethernet connected and both are on the same subnet this has\u00a0caused\u00a0NetBEANS to hang for us after entering the username and waiting for the password prompt.<\/p>\n<p>Can you connect at all<\/p>\n<p style=\"margin-left: 40px;\">If the network connection good &#8211; can you SSH into the RPi using the same login\u00a0from a SSH client OK?<\/p>","protected":false},"excerpt":{"rendered":"<p>Compatability We&#8217;re still using this in 2023 with NetBeans IDE 11.0 with no problems. See here for the netbeans 11 setup. Enabling\u00a0Running Remote Projects in NetBeans\u00a0As 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. \u00a0There are ways to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[95],"tags":[],"class_list":["post-1948","post","type-post","status-publish","format-standard","hentry","category-netbeans-windows"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=1948"}],"version-history":[{"count":24,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1948\/revisions"}],"predecessor-version":[{"id":3686,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1948\/revisions\/3686"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=1948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=1948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=1948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}