You need three things to use Netbeans for your Foundations I or II courses.
- A current, mainstream version of the Java Development Kit environment (JDK)
- The current NetBeans Integrated Development Environment (IDE)
- The proper C and C++ Compilers (gcc/g++)
Note: Downloading on the UARK Guest Wi-Fi network may present problems. Please log in to the UARK Wi-Fi or connect via Ethernet to the on-campus network.
Installing the Java JDK
NetBeans requires that the Java JDK be installed before you attempt to install NetBeans.
Note:(this may change in the future)If you are using Ubuntu and want to use apt to install Java (the clean way) just run:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt install oracle-java9-installer
sudo apt install oracle-java9-set-default
For Manual install (everyone else):
- Go to Oracle’s Website to download the JDK for your operating system
- Click the Java Platform (JDK) button. It should be similar to the one below.
- Scroll down (if necessary) to the grayish box that says: “Java SE Development Kit x.x.x” (x.x.x being the version number) and click: “Accept License Agreement”
- Choose the version that matches your operating system. (Ubuntu users should select the .tar.gz version and not the .rpm)
- Building and Installing the JDK:
- Windows: Click run or open in your downloads list or in your Downloads directory when the download completes.
- OS X: Install using the DMG as you normally would. (Mount the installer and follow the instructions)
Linux Manual Install:
Extract the tarball (tar -zxvf <java archive> -C /usr/java) and update /etc/profile (or /home/<username>/.bashrc to include the line:
export JAVA_HOME="/usr/java" export PATH=$JAVA_HOME/bin:$PATH #Do not copy/paste this line! Type it.
Reboot before continuing
Note: NetBeans should work with the most recent, stable, build of openjdk as well
Ensure JDK is installed correctly
Open up a command line and run the following:
You should see the version print out. If not, make sure you followed all steps correctly.
(If the Linux manual install isn’t working, consult Oracle’s help pages)
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.
Note: For Foundations 1 and 2 you will primarily be working in C/C++. If you don’t have a lot of space or have a slow connection, you may download just the C++ version for your OS.
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
close NetBeans before performing the next step
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”. (You can also do this by searching “Env” in the Start Menu. 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.” This should remove any corrupted configuration entries and fix the problem.