You need three things to use Netbeans for your Foundations I or II courses.
- The correct version of the Java Development Kit environment
- The Netbeans 7.3.1 (or higher) Integrated Development Environment (IDE)*
- The proper C and C++ Compilers
- to be sure to configure your installations of Netbeans and the compilers to work together. This will not happen automatically!
The UA Wireless network WILL NOT WORK for downloading software listed below. You must use UA Secure or a dedicated wired connection.
*Note: 7.3.1 and the newest JDK will only run on Macs with OS 10.7.3 or higher. If your Mac has an older OS (go to the Apple button, then “About This Mac” to check), download Netbeans 6.9.1 instead. The following instructions should work for that version as well.
Installing the Java JDK
Netbeans requires that the Java JDK be installed before you attempt to install Netbeans.
Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlto download the JDK for your operating system.
If you need more information, this link has all of Sun’s Java installation notes: http://java.sun.com/javase/6/webnotes/install/index.html
On the Netbeans download screen, select the correct operating system from the drop-down in the upper right. Choose the version with ‘All’. It’s a good idea to select the default install location and packages.
After installing Netbeans, you will have to activate the C++ tools. Go to the Tools menu, and open the Plugins dialog window. From there, select the Installed tab, and activate the C++ module.
If you need more information, go to: https://netbeans.org/community/releases/73/cpp-setup-instructions.html
Installing the C++ compiler
In order for Netbeans to compile and run your C++ programs, you must also have a C compiler, C++ compiler, make utility, and gdb debugger.
For Windows: You need to download and install a program called Cygwin in 32 or 64 bit depending on your computer type. During the install a list of all the available packages will appear for you to download. Click the “+” next to “Devel” to expand a list of packages. Click the “skip” label next to the following packages to select them for install: “gcc-core”, “gcc-g++”, “gdb”, and “make”. Click next and the required four packages should be installed under C:\cygwin by default.
Add the Cygwin directory to your system path variable by going into Start > Settings > Control Panel and click “system”. Go to the advanced tab and open Environment Variables. Under the second label titled “System Variables”, select “Path” and then click edit. Add the location of the Cygwin bin folder from where it is installed (usually C:\cygwin\bin) to the list of variables and save it. Once this step is completed, Netbeans should automatically detect and use the compiler. You should now also be able to compile C and C++ code directly from the windows command prompt using commands “g++” and “gcc”.
- If after following all instructions carefully Netbeans still isn’t working, try restarting Netbeans and/or your computer.
For Mac: Install Xcode from the Mac App Store (you will need an Apple account), then open Xcode, go to Xcode -> Preferences, then the Downloads tab, next to Command Line Tools click install.
Note: the latest version of Xcode does not install the C++ compilers by default. You must select it manually. It is classified as a ‘optional component’/’command line tool’
A strange problem that might be encountered: sometimes, you run your first C++ program and while it compiles and runs fine, the IDE is still showing multiple errors, especially on the libraries. Google has several different solutions, but one thing you should try first is going to NetBeans > Preferences > C/C++ > Build Tools and click “Restore Defaults”. If the errors are still showing after you click into the code file, go back to the C/C++ menu, click “Project Options,” and check “Show binary files in Project view.” I’m not entirely sure which of these worked, but one of those two fixed the problem for me and the errors went away.