COP 2805C (Java II) Project
Practice Using Eclipse, NetBeans, IDEA, and Maven

The IDEs project

Due: by the start of class on the date shown on the syllabus

Description:

For this project you will install and then explore three IDEs: Eclipse, NetBeans, IntelliJ IDEA.  In any case, you will need to have installed the JDK too, which in turn includes a JRE.  In addition, you will learn and explore using the non-GUI project and dependency management tool, Maven.

Complete directions for installing all software as used in the classroom can be found in the course resources, in the Java Setup link.  (Those directions have not been updated for nearly a year, but they might still be useful.)  What follows are the brief directions for setting up the three IDEs and Maven.

For each IDE (and Maven), you must modify the generated Java file: make changes, make various errors, and learn to use the tools to fix such errors.  Unmodified Java files will not count for full credit!

Part I — Eclipse

  1. Download and install the current release of Eclipse from eclipse.org.  On the right, you will see the installer eclipse-inst-win64.exe link to download the Windows 64-bit installer.  (Notice the “.dmg” download link for Mac OS X users.)  Run the installer.  For our class, choose either the Java SE or Java EE packages.  (The EE package includes everything in the SE package.)

    An alternative to the installer is to download a zip of the version you want, from www.eclipse.org/downloads/packages/.  The zip version can be installed on a flash drive, so you can take Eclipse with you and use from any computer!

    For Windows, download the “zip” file for Eclipse (the 64-bit version, if you have the 64-bit JDK) and extract the contents into “C:\Program Files”.  This creates a new sub-directory “eclipse”.  Open that folder and right-click on the file eclipse.exe.  Choose “Copy”.  Next you might want to make a short-cut on the start button.  With Windows 7, right-click on the “Start→All Programs” button and click on “Open”.  Next open the “Programs” folder.  Right-click in this window and choose “Paste Shortcut”.  With Windows 10, open the File Explorer and navigate to the folder where Windows 10 stores your program shortcuts: %AppData%\Microsoft\Windows\Start Menu\Programs.  Right-click in this window and choose “Paste Shortcut”.  (You can add additional short-cuts to your desktop or pin eclipse to the quick launch bar, if desired.)

  2. Eclipse is now installed and ready to use.  Go and launch it.  It may ask a few questions such as where it should keep its files (the Eclipse workspace).  You can put this anywhere you like.  Personally I prefer to use either “Documents\Eclipse-workspace”.  (You can click the button to make Eclipse remember your choice.)
  3. Before getting started, it is a good idea to go to the “Help” menu and select “Check for Updates”.  (Be sure to configure all available sites before checking, or updates won't be found!)
  4. From the Welcome page (you can make that show from the Help→Welcome menu), read some of the tutorials including at least Workbench Basics (also called the User Guide) → Getting started → Basic tutorial, and Java Development → Getting started → Basic tutorial.  (This will give you an overview on how to use and configure Eclipse.)  You might want to read about Git, Maven, or other topics; examine the list for any that seem interesting.  (You won't have time to read them all now, but you should attempt to read some of them over time to improve your skills.)

    You can also read the Eclipse Documentation online, especially the Workbench User Guide and the Java Development User Guide.

    Additionally, you can read this tutorial which I found to be well-written: www.vogella.com/tutorials/Eclipse/article.html.

  5. Eclipse supports plug-ins, many of which are freely available.  These are just jar files placed into the Eclipse install directory.  There are hundreds available to extend Eclipse with additional functionality, such as XML editors, Junit test case editors, UML GUI drawing tools (that generate Java code for you), and Java EE tools.

    A collection of these projects useful for Java and Java EE development has been bundled together, which is what you have installed (the current version of Eclipse).  To install other Eclipse plug-ins not included with your installer bundle:

    1. Under the Help menu, click on “Install New Software...”.  Now tell Eclipse where to look for the new plug-ins.  You should select “--All Available Sites--”, but to add some third-party plug-in you need to add their site to the list, by clicking on the “Add...” button.
    2. On the bottom of the window are a bunch of check boxes, for things such as “Only show the latest versions” and “hide items that are already installed”.  I would check all these items to limit the list of available software to only the plug-ins you are actually interested in seeing.
    3. Check the check-box next to the items you want (and don't already have installed), and then click on the Install... button.  For example, try adding Gonsole or the latest version of the Web Tools Platform (WTP), and click “Next”.  This shows a summary of all the items that will be installed based on your choices.  Click “Next” show the license screen; be sure to select the “I agree ...” button, then click on the “Finish” button to start the install.

    Feel free to explore other available plug-ins.  Even more plug-ins can be found at marketplace.eclipse.org.  (Warning: You should learn the basic Eclipse platform first, because adding plug-ins complicates the user interface.)  I like adding SpotBugs (replaces FindBugs).

  6. Once plug-ins are installed, you will want to keep them up to date.  Just select “Check for Updates” from the Help menu.
  7. You can explore the preferences and make a few changes, but don't make too many changes until you have learned Eclipse better (or the tutorials won't match what you see!).  However, you should explore what preferences are available and how they are organized.  You will likely want to configure some defaults (for file encoding and line endings, or change the user interface the way you like it.
  8. Explore the other features of Eclipse.  This is the whole point of this project, so spend some time trying stuff out.
  9. Start a new Java project, then add a new class Hello.  (Be sure to check the “Generate comments” checkbox.)  You should see a new file “Hello.java” in the Package Explorer window.  Right-click on it and chose open (or double-click it), and create a hello world (or other simple) application.
  10. Note the Eclipse won't automatically put your classes in packages.  That is fine for this project, but generally it is best to use packages.  You can name your package anything you wish, such as reusing the project name.
  11.   Add some code.  Your application should not be identical with the tutorial; make yours say something such as “Hello from the world of Eclipse!”.  Don't forget to add appropriate comments (and to delete or modify the pointless comments that Eclipse inserts automatically for you).  Run your project and make sure it is working.  Make some deliberate errors in your program, and see how you can fix them using the Eclipse features (try right-clicking on the error).

Part II — NetBeans

Oracle gave NetBeans to the Apache foundation.  Apache recently (end of 2018) released the new version that works with Java 11.  However, the website is not polished, and they are still working on porting the old documentation and updating it; much of it is very old.

  1. Download and install the latest stable version of Apache NetBeans.  (At the time of this writing, NetBeans 10 is the latest.)  Apache NetBeans doesn't include any installer, just a zip file.  Extract the contents (a folder named netbeans) into “C:\Program Files”.  To launch, double-click netbeans.exe.  Follow the same steps as with Eclipse to add shortcuts to your Start menu or desktop.

    I don't believe there is any official Apache NetBeans download for Mac OS X at this time, so you can skip this part if you only have a Mac.  However, a student showed me a non-standard installer you can try.  Follow the directions at github.com/carljmosca/netbeans-macos-bundle.  (Note I've not tried this, so use at your own risk.)

  2. After the install is complete, you will want to update your software.  Use the “Help→Check for Update” to do this.  Like Eclipse, NetBeans has many plug-ins available you can install.  As I mentioned above, you probably shouldn't install many until you know the IDE better.
  3. You can read on-line tutorials and documentation from www.netbeans.org/kb/, but be aware that many of them are not updated since NetBeans 8.  Feel free to read those and at least read the “NetBeans IDE [Java] Quick Start Tutorial” and the “General Java Development → Java Quick Start Tutorial” and “General Java Development → Developing General Java Applications” guides.  You may also find some of the (older) NetBeans video tutorials useful, such as “Java Editing in NetBeans IDE” or NetBeans IDE tutorials on YouTube.  I have no doubt YouTube (and elsewhere) have many tutorials on the newer versions of NetBeans; just search for them.

    You might want to read about Git, Maven, or other topics; examine the links for any guides/tutorials that seem interesting.  (You won't have time to read them all now, but you should attempt to read some of them over time to improve your skills.)

  4. Explore the features of NetBeans.  You should spend some time doing this, since learning to use the IDE is the whole point of this project.
  5. You can explore the preferences and make a few changes, but don't make too many changes until you have learned NetBeans better (or the tutorials won't match what you see!).  However, you should explore what preferences are available and how they are organized.  You will likely want to configure some defaults (for file encoding and line endings, or change the user interface the way you like it.
  6. Create a simple “Hello World” type of Java application using Apache NetBeans.  To create a new Java application using NetBeans, use the File menu and click on “New Project...”.  Next select “Java Application” from the “Java” category, and click “Next”.  This may ask you to “activate” the feature (Java).  If asked, go ahead and activate.

    Give your project a useful name (e.g., “hello”), and pick a name for the class that will be generated (e.g., “hello.Hello”).  Note the NetBeans automatically puts your classes in a package named after the project.  That is fine, but for this simple project, you could put your class in the default, nameless package (or pick a different package name).  Leave “Create Main class” selected; note you can change the class name if you want (I like Main).  Click “Finish”.

  7. Now add some code.  Your application should say something such as “Hello from the world of NetBeans!”.  Be sure to add appropriate comments (and delete any empty or pointless comments that NetBeans may automatically add).

    Run your project and make sure it is working.  Make some deliberate errors in your program, and see how you can fix them using the NetBeans features (try right-clicking on the error).

Part III — IntelliJ IDEA

IntelliJ IDEA (often just referred to as “IntelliJ” or “IDEA” IDE) is a popular commercial IDE from the company JetBrains.  It comes in a free community edition (fully-featured but limited to Java SE) or in the commercial (costs money) “ultimate” edition (supports Java EE too).  Currently, the ultimate edition is free for a year if you register as a student.

  1. Download and install the latest stable version of IntelliJ IDEA Ultimate.  Note there are installers for Windows, Mac OS X, and Linux. Run the installer.  When done, you have a 30-day license.  To obtain an activation code for a free one-year student subsection, follow the directions at www.jetbrains.com/student/.

    As with other IDEs, you can add plugins for extra functionality.  I suggest you don't add many until you know the IDE better.

  2. You can read on-line tutorials and documentation from www.jetbrains.com/idea/documentation/.  Feel free to read those and at least watch the “Running IntelliJ IDEA for the First Time”.  You might want to read about Git, Maven, or other topics; examine the links for any videos/tutorials that seem interesting.  (You won't have time to read them all now, but you should attempt to read some of them over time to improve your skills.)
  3. Explore the features of IDEA.  You should spend some time doing this, since learning to use the IDE is the whole point of this project.  Like the other IDE there are many plugins you can add. 
  4. You can explore the preferences and make a few changes, but don't make too many changes until you have learned NetBeans better (or the tutorials won't match what you see!).  However, you should explore what preferences are available and how they are organized.  You will likely want to configure some defaults (for file encoding and line endings, or change the user interface the way you like it.
  5. Create a simple “Hello World” type of Java application using IntelliJ IDEA.  To create a new Java application using IDEA, click on “Create New Project” from the welcome screen.  Next tell IDEA where to find your JDK.  (You only should need to do this the first time.)  Click Next.

    Click the checkbox to “Create project from template”, and select the command line application template.  Click next.

    Give your project a useful name (e.g., “hello”), and pick a name for package.  For this simple project you could put your class in the default, nameless package (or pick any package name).  Click “Finish”.  Notice the template created a class named Main.  You can rename that if you like.

  6. Now add some code.  Your application should say something such as “Hello from the world of IntelliJ IDEA!”.  Be sure to add appropriate comments (and delete any empty or pointless comments that IDEA may automatically add).

    Run your project and make sure it is working.  Make some deliberate errors in your program, and see how you can fix them using the IDEA features (try right-clicking on the error).

Part IV — Using Maven

Read the Maven in 5 Minutes tutorial.

  1. Install Maven on Windows (See the box below for Mac directions):
    1. Download the zip archive of latest version of Maven.  Be sure to download the binary zip, not the source (“src”) zip!
    2. Extract it to someplace.  I suggest C:\Java\ (used in the directions that follow), but anyplace you wish is fine.
    3. I suggest you rename the folder from apache-maven-version to something simpler, such as just maven.
    4. Add this entry to the PATH environment variable: C:\Java\maven\bin (use the folder name you picked).
    5. Add this new environment variable: M2_HOME=C:\Java\maven
    6. Make sure you have the following environment variable set: JAVA_HOME=C:\java (or whatever location you used for the JDK).

    (As a reminder: PATH is used by your system to locate executables such as mvn or java; CLASSPATH is used by Java to locate packages and some other things; JAVA_HOME is used by various programs (including Maven) to locate a JDK; and M2_HOME (previously known as MAVEN_HOME) is used by mvn to locate various configuration files.  All of these may be used by other programs to locate files they need.  While some programs are smart enough to guess to try default install locations when you don't set these variables, that won't work if you don't install in the default locations.)

    Install Maven on Mac OS X

    There are several ways do to this.  One is to follow the standard install directions for a Linux-like system, found on the Maven website.  The simplest way seems to be this:

    1. Install Homebrew if you don't already have that: visit brew.sh, copy the long line shown, and paste it in a terminal window.  Doing this provides you with the brew command to install things.
    2. Run the command brew install maven.
    3. If your version of OS X doesn't include the tree command, you can install that using the command brew install tree.
  2. First, pick (or create) an empty directory to hold your Maven projects, and cd into it.  (Over time you will have many programming projects and your desktop or home directory will become cluttered.  I use “Documents\Java Projects” for this.  Next, create a working “Hello, World” project named “hello” using the command (one long line):
    mvn archetype:generate -DgroupId=cop2805 -DartifactId=hello -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
    

    (Here we use the latest version of that archetype as of 1/2021.  If there's a newer version available, consider using it instead.)  The artifactId will become the name of the project's folder.  The groupId becomes the package name for your code.

    That command might take a while the first time.  When done, see what files were created by using the tree/F hello command (just tree on Mac or Linux).  Also take a look in your home directory; you should see a new subdirectory there named .m2.  That's your personal Maven repo.  It can contain settings files as well.

  3. Next cd into your new hello directory.  Take a look at the generated source code at src/main/java/cop2805/App.java, the generated unit test at src/main/java/cop2805/App.java, and the generated pom.xml file.  (When using Maven “for real”, you would edit the POM file and then edit or replace the App.java and AppTest.java files.)
  4. To use a modern Java version, you will need to change some lines in your pom.xml file.  The reason is, the current version of Maven's compile plugin tries to generate code compatible only with Java 7 (“javac -target 1.7 -source 1.7”).  To compile and run using a different Java version, you need to modify these two lines in your generated pom.xml:
      <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
      </properties>
    

    (Those lines can go anywhere between the initial <project> tag and the final </project> tag, but not inside of any other tags.  Just above the final </project> tag is fine.)

    While your at it, you can change the JUnit version from 4.11 to 4.13.1.

  5. Next, compile, test, package, and install your project.  (Remember, you can only run most Maven commands from within a project directory, one that contains a pom.xml file.)  Maven will automatically put a copy of the resulting jar file into your local repo, ~/.m2/ (“~” means your home directory) when you run mvn install.  This is done with the simple command:
    mvn install
    

    If the build was successful, the application will be found in a jar file in the target subdirectory.  To run your new app, enter this command (without changing directories first):

    java -cp target\hello-1.0-SNAPSHOT.jar cop2805.App
    

    Run the tree/F (or tree) command to see all the new files created.  Also look in your home directory and use tree on the .m2 directory there.

    Make some errors in the code and see what Maven says when you compile and test the code.  (Unlike IDEs, Maven doesn't include any features to help with errors.)

  6. Consider adding some extras to Maven.  I like Maven versions plugin, the Exec Maven plugin, the Spotbugs Maven plugin, and others.
  7. Finally, there are a couple of other Maven commands to play with:
    • Try “mvn site” to generate a website for your project.  You can view the site in your web browser by opening the file “.../hello/target/site/index.html”.
    • Convert your Maven project to an Eclipse-Maven project: “mvn eclipse:eclipse”.  If you import this project into Eclipse, it should just work.
    • Try to convert your “Hello, world” projects from the two IDEs into Maven projects.  Notice how the layout of folders is now different from the default for your IDEs.

Part V — Questions to Answer

  1. What other IDEs are available for Java programming?  Name at least two besides the three covered in this project.
  2. Based on your experiences so far, which IDE do you prefer?
  3. Which developer feature(s) did you like better in Eclipse then the others?
  4. Which developer feature(s) did you like better in NetBeans then the others?
  5. Which developer feature(s) did you like better in IntelliJ IDEA then the others?
  6. Why do you think Maven (a command line tool but can also be used with a GUI IDE) is so popular?

To be turned in:

A copy of your Java source code from the “Hello World” programs you created in parts IIV, the pom.xml file created in part IV, and the answers to the questions asked in part V.  Submitting all six files at once is easier to grade than submitting a zip, but either way is acceptable.

When copying from Eclipse, copied code loses all formatting if any of the code is “folded” (hidden with a plus sign where the missing lines are).  To avoid losing formatting when copying, first right click on the line numbers and select Folding → Expand All.  Now when you copy, all formatting should still be there when you paste!  (To prevent folding altogether, go to Window→preferences→java→editor→Folding, and select/unselect the various folding options.)

You can send as email to (preferred).  If email is a problem for some reason, you can send a message to me using Canvas, and attach a zip of your files to it.  Or, you may turn in a hard-copy as a last resort.  In this case the pages should be readable, dated, and stapled together.  Your name should appear on the first page.

Submit to the correct Canvas dropbox for this assignment.

Please see your syllabus for more information about projects, about submitting projects.