Netbeans HOWTO - Computer Science and Computer ...

hundredhonkΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 2 μήνες)

519 εμφανίσεις

University of Arkansas

College of Engineering

Computer Science & Computer Engineering (CSCE)


Netbeans HOWTO;

A Guide to Installing and Configuring Netbeans 6.9.1 under Ubuntu Linux, MS
-
Windows and Mac OS X

Latest Update: January 20, 2011

Document Rele
ase History:

Main Author
-
Paul Walton

-
August 18, 2009

Revisions, HTML
-
ification
-
Tyler Moore

-
January 14, 201
1

Further Revisions
-
George Holmes

-
January 20, 201
1

Introduction


This HOWTO will walk you through installing Netbeans on your personal com
puter, and
use it to compile C++ code on on your system AND on the CSCE Dept's compute server,
Turing.csce.uark.edu. It will also assist you in using Netbeans in the CSCE Acxiom
computer lab (room 215), and programming foundations labs (room 235).


You are
not required to install Netbeans on your computer. If you don't have a computer,
or do not want to do this install, you can still access Netbeans from any CSCE lab
computer. But installing Netbeans is highly recommended, as you'll then be able to do
homew
ork assignments without having to come to the campus lab, learn about coding for
different platforms/environments, and also gain additional skills in installing and
configuring your own computer software.


NOTE: This guide is NOT a guide for programming.
Your textbook, lab teacher and
course professor will fill that role.


Table of Contents

1.
Before You Begin

1.1
Platform and Architecture Considerations

1.2
What Your Instructor Will Expect

2.
Installing the Java JDK

2.1
Windows XP and Vista

2.2
Linux

2.3
Mac OS X

3.
Installing Netbeans

3.1
Windows XP and Vista

3.2
Linux

3.3
Max OS X

4.
Using Netbeans at Home

4.1
Local Compile

4.2
Remote Compile

5.
Using Netbeans in the CSCE Computer Labs

5.1
The Linux Terminals (JB
HT 215 and 235)

5.2
Windows and Mac OS X (JBHT 215)

6.
Using Netbeans O
ver SSH With X Forwarding



1. Things to Consider Before You Begin


New student
-
programmer? Experienced student
-
programmer? It doesn't matter.

1.

Not all computers are the same. What works on one is not
guaranteed to work on
another. In a CSCE course, your instructor will often use a specific scenario to
test the code you submit for grading. So should ...

2.

Test your code under the same environment in which it will be graded. It's no fun
to see your code wo
rk on your Windows 7 laptop but discover that it fails horribly
when your instructor tests it on Turing after you turn it in.

3.

Submit your program/code when it is due, even if it doesn't work perfectly! If you
submit nothing that's the grade you'll get. So
me instructors awards partial credit,
and even if your's does not, then at least there's the opportunity for review your
work and helpful feedback, which can certainly help on the NEXT assignment.


1.1 Platform and Architecture Considerations


One of the b
iggest complaints from a student is that their program will compile perfectly
on their home computer, but fails on the school computer that the instructor is using to
grade the student's work. This is typically because of some type of platform or
architect
ure differences between the two computers. For example, code written for a
Windows machine will not run on a Linux machine. However, one thing that many
people tend to overlook is that a program compiled on a 64
-
bit system will fail to run on a
32
-
bit syst
em, and it's not guaranteed that a 32
-
bit program will even run on a 64
-
bit
system either. You need to take considerations like this into account when you write your
programs. Your code should be written with a target platform in mind, from the start. If
y
ou compile your program as a 32
-
bit Windows executable, then it will be guaranteed
NOT to run on our 64
-
bit Linux server, and vice versa!


1.2 What Your Instructor Will Expect


First, and foremost, you should always ask your instructor what they expect from
you and
your assignments. They are the best source for that type of information, and can clarify
any misunderstandings you might have. However, you should keep the following
considerations in mind as you write your programs.

Your instructor is very likely
to compile and run your code on the CSCE 64
-
bit Linux
server, Turing. This server is running 64
-
bit Ubuntu Linux 10.04, with Netbeans version
6.9.1. This is the LTS, or Long Term Service version of Ubuntu that is currently
available. So, if you want to en
sure that any programs you write will compile and run on
the CSCE Linux server, Turing, then you should be using a computer that has a 64
-
bit
processor, running 64
-
bit Ubuntu Linux 10.04. However, your best option is to actually
compile and test your code
on Turing itself, since that will guarantee it will work when
your instructor attempts the same thing. You aren't required to use Ubuntu 10.04, but it
may help eliminate any unwanted headaches. In fact, most of this document is dedicated
to showing you how
to use various alternatives that you may encounter.


2. Installing the Java JDK


Netbeans requires that the Java JDK be installed before you attempt to install Netbeans.
This may be, in part, because Netbeans is actually written in Java. There are versions
of
the JDK installer that come bundled with Netbeans, which are perfectly fine to use if you
want to, but this process will show you how to install the JDK separate from Netbeans
just in case you want a different version of either one than what comes bundl
ed together.
(i.e. You want the newest version possible.)

Rather than duplicate Sun's documentation, I've opte
d to provide links to their own
guides on this subject. Only the major highlights will be pointed out to you in this
HOWTO. Adventurous readers ar
e encouraged to read all of the guides mentioned here,
but feel free to jump to the sections that only apply to your scenario.

The only exception to this is the Mac OS, which doesn't have a Java JDK download from
the Sun website, yet Netbeans will still in
stall. I'm assuming that Mac has their own
version of Java that is being used instead.


This link has all of Sun's Java installation notes:

http://java.sun.com/javase/6/webnotes/instal
l/index.html

This link has all of Sun's Java downloads:

http://java.sun.com/javase/downloads/index.jsp


2.1 Windows XP and Vista


Installing the Java JDK on Windows XP or Vista is a relatively p
ainless procedure. All
you need to do is download the executable, and run it as the administrator. However, for
a full in
-
depth explanation, please read Sun's documentation at the link below.

http://java.sun.com/javase/6/webnotes/install/jdk/install
-
windows.html


2.2 Linux


There are several ways to install the Java JDK on a Linux system.

The easiest way is to use the packaging tool that comes with your particular flavor
/brand
of Linux. For advanced users, you can also download the self
-
extracting binary, and
install it manually.

Most, if not all, Linux flavors have some type of package
management software, and in general that's the way to go, especially if you're new to

Linux. Be aware that the software repositories for these packages are not always the latest
version of the Java JDK.

On Ubuntu, and other Debian flavors, the most basic packaging tool is called Apt, but
unless you are experienced, you'll want to use one
that's bit nicer called Aptitude. If
you've installed Ubuntu at this point, stick with the Aptitude package installer.
Distributions like Redhat, Fedora, CentOS, SuSe, etc., are RPM
-
based Linux's, and you
would use the Yum package installer.

Since Ubuntu is what is running on Turing, and so, what you will be using in the course
lab work, choosing this particular platform. is a good choice. The remainder of the Linux
section HOWTO will assume that this is the case.


To install the Java JDK on
Ubuntu, just type the following command into the terminal:

sudo aptitude install openjdk
-
6
-
jdk openjdk
-
6
-
jre

(NOTE: you'll be prompted for whatever password you set when you installed Ubuntu)

However, if you truly want the most current version of the Jav
a JDK then you will need
to follow Sun's instructions on their website below.

http://java.sun.com/javase/6/webnotes/install/jdk/install
-
linux.html

2.3 Mac OS


This secti
on is a placeholder.


3. Installing Netbeans


The install process for Netbeans is almost identical on Windows, Linux, and Mac. The
only difference is in which of the downloads you choose

and run.

Basic Instructions:

From the Netbeans website listed below
, choose your operating system (from dropdown
box in upper right), and select to download the package containing all of the Netbeans
components you need.

Then, using your computer's Administrator account/password, you should run the install
program you j
ust downloaded. It's a good idea to select the
default install
location and
packages. At this point, Netbeans should install itself automatically on your system.

After installing Netbeans , you will have to activate the C++ tools. Do this

To activate t
he C++ tools, go to the Tools menu, and open the Plugins dialog window.
From there, select the Installed tab, and activate the C++ module.


The following links contain everything you need to install Netbeans:

Download page for all platforms and versions:

http://www.netbeans.org/downloads/index.html

(NOTE: Unless you need other coding environments, choose the C/C++ download)

Installation instructions:

http://www.netbeans.org/community/releases/69/install.html

Setup and configuration instructions page for C/C++ Programming:

http://www.net
beans.org/community/releases/69/cpp
-
setup
-
instructions.html



3.1 Windows XP and Vista


In order for Netbeans to compile and run your C++ programs on your local Windows
machine you must also have teh C++ compiler installed. This is available for Windows as

part of a program call
Cygwin
. This is a Unix emulator for Windows, which allows you
to use the GNU C++ Compiler to test your code in a semi
-
native Linux environment.

Sun's documentation does an excellent job explaining how to install and configure
Cygw
in for Netbeans, so use the first link below to do that... but basically, you'll
download the Cygwin installer (called setup.exe), run it, select what parts or packages
you want to install, and you're done. Netbeans will automatically detect this Cygwin
en
vironment the next time you start Netbeans and create a new C++ project on your
computer. NOTE: the Cygwin packages you need to make sure you get installed are
GCC, G++, GDB and Make.


Follow the links below for instructions on Cygwin setup:

http://www.netbeans.org/community/releases/69/cpp
-
setup
-
instructions.html

Cygwin Main page:

http://cygwin.com


Download Cygwin setup file here:

http://cygwin.com/setup.exe


3.2 Linux


The only thing you need to be aware of is that the install program you download from the
Netbeans website won't have execute permissions. In order to
run the program you will
need to change the permissions first. Just run the command below to do this.

sudo chmod 755 netbeans
-
6.9
-
ml
-
linux.sh

Once you have given the install program execute permissions, just run the installer as
root, and select the defaul
t location and packages. However, the install program uses an
X.org GUI interface, which means your system will need to have the X.org packages.
The default installation of Ubuntu Desktop will automatically install X with the Gnome
interface, which is perf
ectly fine. If you install Netbeans as Root then all users on the
system will have access to it, not just your user. However, you are free to install it as any
user your want, just remember that this user will be the only one who can run Netbeans.
If you w
ant to compile C++ programs on a Linux machine using Netbeans then you will
need to install the following packages; GCC, G++, GDB, and Make. These are the GNU
C++ compilers that Netbeans will use. Just type the command below to install these
packages using
Aptitude.

sudo aptitude install gcc g++ gdb make

Once you have the GNU compilers installed Netbeans will automatically detect them the
next time you create a new C++ project.

Alternately, if you prefer to use Ubuntu's packaging service you can type the fo
llowing to
install Netbeans 6.8.0 through Aptitude. Note that this is not the most recent version of
Netbeans.

sudo aptitude install netbeans


3.3 Mac OS


Installing Netbeans on the Mac OS is as easy as downloading the install program, and
running it. Selec
t the default location and packages, and you're good. However, if you
want to use Netbeans to compile C++ programs then you must install the X11 and Xcode
packages that are provided with your Mac OS.


The following links tell you everything you need to know
:

http://www.netbeans.org/community/releases/69/install.htm

http://www.netbeans.org/community/releases/69/cpp
-
setup
-
instructions.html


4. Using Netbeans at Home


Regardless of what operating system you use, the Netbeans interface is the same.
Therefore, the instructions for using Netbeans are the same across Windows
, Linux and
Mac.

Suggestion:

You may want to keep your C++ project on a USB memory stick, especially if you don't
want to lug your laptop everywhere, or you plan on using more than one personal
computer/laptop to do your work.

When you create a new pro
ject in Netbeans, it will ask you where to store the project
files, ...

just select your USB memory stick as the drive you want to use.

Later, when you want to open the project on another computer, you just open the project
files stored on your USB driv
e, and eliminate the mess of remembering what computer it
was stored on, or if you copied the most recent version to the machine you want to use.
Plus, you won't have multiple versions floating around on different computers that can
lead to confusion.

Bu
t, it is always wise to have a backup somewhere, just in case you lose or break your
USB memory stick!


4.1 Local Compile


Compiling and testing your programs locally on you're home computer is a relatively
easy thing to do. If you've followed the instructi
ons above for installing the
Java JDK

and
Netbeans,
and successfully configured your system to compile
C++
programs, then
you should be ready.

All you have to do is create a new C++ project, and press the build button. The only
troublesome part is rememb
ering that, just because it works on your computer, doesn't
mean it will work on Turing, which is a 64
-
bit Linux server where your instructor will
grade your assignment.
Always test your code on Turing before you submit it.

However, don't be afraid to do
your homework on your home computer,

but always keep
in mind that your instructor will test your code on Turing, so be sure to test there before
you call it done.

What if you want to actually work on your pc, but compile your programs on Turing?
That's
the best of both worlds... working where it's convenient, but compiling on the
server you know is the place it must work. That leads us to the next section...


4.2 Remote Compile


Setting up your local computer's Netbeans program to compile your
source code on
Turing.csce.uark.edu, the CSCE Department's 64
-
bit Linux server, requires a few steps to
achieve. We have a description of what to do below, but no matter how it's written there's
always a place you might go astray. Read it carefully.

1.

Start
Netbeans

2.

Select the Tools menu

3.

Open the Options dialog window

4.

Select the C/C++ tab

Under the Build Tools tab you should see a setting for the Development Host, which
should currently be set to
Localhost.
Localhost is your own computer, and will use the

GCC utilities you installed with Cygwin. So, you want to add a new host, and tell it to
use the GCC tools on Turing instead. So,

1.

Click on the
Edit
button next to
Development Host, and
the
Development Hosts
Manager
dialog should open.

2.

Select the
Add
bu
tton and type
turing.csce.uark.edu
in the
Hostname
textbox

3.

Click
Next
. and enter your UARK
user name
and
password
(DO NOT tell it to
remember your password)

4.

Click
Next
again. Netbeans will now go through a discovery phase where it will
actually log into
Turing, and it will find the path to the GCC tools it will need.


After this discovery phase is completed,

5.

Click
Finish
.

You can now choose to set turing or localhost as your default development host. There is
debate as to which is the best choice. Leav
ing it with Localhost as your default
development host means you are able to code and compile without any network
connection to your pc (but you'll still have to test on turing at some point). Setting the
default to Turing will require the network connecti
on to get any work done, but at least
you'll know it works as expected.

Finally, proceed to the
Project Options
tab directly to the right of the Build Tools tab
and deselect the "
Show profiler indicators during run
" checkbox.

At this point you are ready
to start compiling and testing your code on Turing. Any new
C++ projects you create will automatically use whatever you chose as your default host,
and so the GCC tools and environment of that location will be used to compile, run and
debug your code.


If
you want to switch environments then simply open the Options dialog, and select the
host you want to use. Using Turing's GCC tools remotely will allow you to do the
following set of things: compile your C++ code on Turing itself, execute your code on
Turi
ng's 64
-
bit processor, and see the output, debug and error messages from Turing's
console.


It will also
copy
the current state of your project to your home directory on Turing,
providing a way to backup your code, and also allowing you another way to acc
ess it at
school in case you forget your USB drive. But, wherever you last saved your project will
be the one you want to return to and use as you continue to work.

You are allowed to have as many hosts defined as you want, so you can easily switch
betwee
n local compile and remote compile by simply changing what host you are using.
This is handy for development, since you can test your code on your local machine while
you are writing the program, and then simply switch your host to Turing to see if it will

work there as well. This also allows you to setup any other hosts you may want or need,
such as compiling on the Lovelace server. If you have created a project and wish to
change the current location which you are using to compile, simply go to that proje
ct's
Properties (right
-
click or control+click for the context menu, then click on Properties)
and go to the Build label on the left. From this pane you can switch the project's compile
location between localhost and any other locations you may have defined

(turing.csce.uark.edu, for example).


5. Using Netbeans in the CSCE Computer Labs


Basically, using Netbeans in any of the computer labs is identical to how you would do it
at home, except you're doing it from a lab machine instead. However, there are seve
ral
important exceptions, which are discussed in the next few sections.


5.1 The Linux Terminals


The Linux terminals are actually using Turing as a compute server. The images on the
screen are being generated by the Turing server, and pushed to the termina
l for you to
view. So, in essence, using one of the Linux terminals in the lab is just as if you were
sitting in front of the Turing server itself. This is the ultimate way of ensuring that your
code will run on Turing, since it actually is running on Turi
ng.


5.2 Windows and Mac OS X (JBHT 215)


The Netbeans installed on the Windows and Mac systems in JBHT 215 are configured as
standalone systems, just as in
section
2
of this guide. If you wish to use the remote
development (remote compile) option, you'll have to do that once you've logged into the
Windows or Mac computer you choose in the lab. In general, you'll probably do better to
just use one of the
Linux Terminal Clients
systems, which are setup the same as those in
the PF lab (JBHT 235).


6. Using Netbeans Over SSH With X Forwarding


This section assumes you already know about using a terminal or console window and
the basics of using SSH (secure shell) to connect a remote host. With it you can connect
to Turing securely, log into a console (terminal) window and establish a session on
the
remote computer, at which point you can manipulate files on the remote system from the
command line. But that's just the beginning.

Additionally, with something called "X forwarding" you can use graphical programs on
the remote system and have them fo
rward the display to your local computer.

So, let's use Netbeans over SSH and you'll see what this does.

Linux and Mac OS X

With Linux and Mac OS X, this X forwarding ability is built in. Open up terminal on the
local pc, and at the prompt type:



ss
h yourusername@turing.csce.uark.edu
-
X

(where yourusername is your unique turing account username you've been using to login
in the lab)

Then, when you've logged in, and have a command prompt on Turing, you can type:



netbeans

In a short (or long*) tim
e you're local computer will display the netbeans program.

MS Windows

With Windows XP, Vista or Windows 7, you'll need to install two programs in order to
have the ssh and X forwarding features. One is an SSH program (we recommend one
called puTTY, which
you can download
here
, and the other is an X server, and the best
one for Windows called Xming, which you can download and install
here
.




The web sites below offer help in installing and using puTTY and Xming. They are not
maintained by CSCE, so the examples they give should be chang
ed to match the users,
servers, domains, etc., which are in our department.


http://www.linux.com/archive/feature/118106
(good description)

http://www.techienote.com/2010/10/x11
-
forwarding.html
(one with pictures!)


Now, just as with the Linux/Mac OS X steps above, you can now connect to turing, and
start netbeans from the command line.


This copy of Netbeans is EXACTLY THE SAME
ONE that you've used in the lab, but
it's displaying back to your machine.... all because of the
-
X option used in the command
above. When you are finished, be sure to exit Netbeans normally, and then at the
command prompt in your ssh window, type
exit
to
end your remote connection.

*One caveat; Netbeans is actually running on Turing, and all of it's graphical output is
being forwarded to your machine over the Internet, you WILL experience a noticeable
lag, depending solely on the quality and speed/distanc
e of your Internet connection.
Using X forwarding from one of the University computers is typically an acceptable
amount of lag, but from off campus it can be painfully slow.