Java Training

farrightSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

207 views

Java Integrated Development
Environments (IDEs)

Written by Jeff Smith


IDEs
-
1


There are numerous good IDEs for Java development,
many of them free


IntelliJ IDEA may be the best and the non
-
profit license
version costs only $100


Here are three leading (free) IDEs


Borland’s JBuilder is (sort of) free

JBuilder 2006
Enterprise becomes JBuilder Foundation in 30 days.
They email you a license key for personal use.


Sun’s NetBeans


Eclipse


JBuilder and NetBeans include GUI builder, while Eclipse
has GUI builder plugins available


In this class, I’ve installed NetBeans 5 and Eclipse 3.2

Why Use an IDE?


IDEs allow for refactoring


rename a class or method, and all instances/references
to it EVERYWHERE are updated automatically


Code completion


You type in an object name and a “.”, and then the IDE
shows you all available methods (including signatures)


Debugging


You just click on a line of code and execution stops
there, allowing you to quickly inspect variables


Code generation


IDEs automate some mundane coding tasks like
creating getter and setter methods for a field


JavaDocs (automatically creates much of it for you)


And on, and on….

Eclipse


The Eclipse IDE was largely developed by IBM


http://eclipse.org/


Very popular and free


Developed with SWT (Standard Widget Toolkit), not
Swing, so it works fine on many OS’s, but there have
been problems with Mac OS/X


Relies on plugins for GUI development (Visual Editor)


You can import existing projects (that use an existing
Ant script) into Eclipse


You can also create a “new” Eclipse project that will
automatically detect and include existing code
(packages) that you may have written


Eclipse is the backbone of the new AWIPS 2 project
being developed by Raytheon

Eclipse Help/Tutorials
-
1

Eclipse Help/Tutorials
-
2

Eclipse Help/Tutorials
-
3

Eclipse IDE
-
1

Eclipse IDE
-
2


Eclipse is highly configurable


Go to Windows menu, Preferences to configure the IDE,
how automatic code generation is formatted, colors, etc


Eclipse has different “perspectives” (or IDE window layouts)


Things look a bit different when you are editing code
(usually done in the Java perspective)


Or when you are debugging code (done in the Debug
perspective)


There is a button for changing perspectives in the upper
right corner of Eclipse (and from the Window menu,
Open Perspective option


Eclipse IDE
-
3


Run Configurations enable you to specify different
configurations for running your program. Go to Run menu,
Run… option


A config can specify a main class (program starting
point), run time JVM options (like memory alloc), etc.


Eclipse and Hello World
-
1

Create a new Java program



File menu, New Project, Java Project (click Next)


Choose project name (e.g. test)


you can either let Eclipse put the project in the default
directory


or you can specify your own directory


Choose "Finish"


Click on "Java perspective" button on upper right


Right click on "test" in the navigator window, and select new
Java class


can specify an optional package name (leave blank for now)


Eclipse and Hello World
-
2


Type in a class name in the box next to "Name:"


can specify an optional superclass


can specify optional interfaces to implement


check the create "public static void main(..." box


click the Finish button


You now have a class which you can edit


type the code in the main method:

System.out.println("Hello");


Click on the Run menu, Run... Option


The class you just created should be your “main” class


Click on the New button on bottom left


Specify any optional arguments on the Arguments tab


Click on the Run button to run your program!

Eclipse and Hello World
-
3


Now add another couple of lines to your Hello World
program


String s = “This is a string”;

System.out.println(“s = “ + s);



Now run the program in debug mode and set a breakpoint
on the second line (above)


Execution should stop there and if you move the mouse
over the variable “s”, you’ll see the value in “s”


NetBeans IDE
-
1


NetBeans is very similar to Eclipse


Developed by Sun (the makers of Java)


Includes a nice GUI builder (called Matisse)


Also completely free (works on all OS’s)


NetBeans IDE
-
2

Which IDE to Use?


Since many people in this class will be working on AWIPS
related development (based on Eclipse), I will use Eclipse in
class


If you love NetBeans, I’ve installed it on every machine and
you are welcome to use it


There is no clear cut answer to the question, which IDE is
the best? Eclipse, NetBeans, and JBuilder are all
comparable (it is unclear, however, whether Borland will
continue to support Jbuilder)


IntelliJ IDEA might be the best of all (for $100)