Install and configure Eclipse for Java

Eclipse and Java JDK

In this guide, you can Install and configure Eclipse for Java. Eclipse is one of the most commonly used Java IDEs (Integrated Development Environment). You can install it from the official Eclipse page:

https://www.eclipse.org/downloads/

After that, you could add some extra configuration and packages to get a development environment ready to work.

General Installation Instructions

Download the package from the Eclipse download page . Then, install the package and follow the instructions of the installer application.

Additional MacOS installation steps

  • After download and install the .dmg package, drag the Eclipse application icon to your Applications folder.

Running Eclipse for the first time

The first time you run Eclipse, you probably be prompted to download and install the JAVA SDK. At this point, you need to click “More Info” to point your browser to the Java JDK download page.

Eclipse JDK installation prompt
Eclipse JDK installation prompt

I recommend to install the Java 8 SDK (download page). You may follow the installation steps of Java SDK for MacOS in this post. After installing the Java JDK, you can continue to run the Eclipse IDE.

Selecting a Workspace

A Workspace is a common place to put your related projects. In other words, it’s a common place to put all your java projects, in the same workspace. Also, you can create separated workspaces to individual or related projects only. The first time, you may want to use the default workspace path (/Users/username/eclipse-workspace in MacOS).

Eclipse Workspace
Eclipse Workspace

After this step, you will get a welcome page with some initial tasks and links. You may want to dismiss this welcome page and uncheck the option “Always show welcome at startup” to start with a blank environment for the next time.

Eclipse Welcome Page
Eclipse Welcome Page
Initial Tasks

Some initial tasks that would be needed, at this point, could be:

  • Review IDE configuration settings: To change the IDE theme, colors, fonts and behavior. It’s a interactive guide to configure your environment:
    • Refresh resources automatically: Useful to avoid working over oudated files (changed externally).
    • Line numbers: Activate line numbers to get a quick view of the code location.
    • Check Spelling: Activate spell checker for content of your code (for Strings and comments, not for instructions)
    • Background Jobs: Activate to hide the active Jobs view.
    • UTF-8 File encoding: Only disable it if you are working with legacy projects by default (encoded in ANSI or ISO).
  • Tutorials: Start with some Java tutorials specially designed for Eclipse.
  • Samples: To start with a full featured application example (Java Editor) to showcase all the most important features of the language and the Eclipse IDE.
  • Create a Hello World Application: A simple tutorial to create your first Java application for beginners.

Install additional components

Install MySQL Connector for Java

If you need database connection to a MySQL server both local or remote, then, you need the MySQL Connector for Java, a JDBC driver to connect to your project using the standard Java JDBC API.

Download the zipped .jar package

Download MySQL connector from the official download page.  Select the Platform Independent (Architecture Independent), ZIP Archive to download. After download, you will be prompted to login or signup for a Mysql site account. Otherwise, you can simply follow the link “No thanks, just start my download.” to download it directly.

Unpackage and copy to your project

Copy the unpackaged jar file (example: mysql-connector-java-5.1.47.jar) into your java project folder.

Add the MySQL connector library to your project

Inside Eclipse, in your project preferences, you can “Add external archives“, selecting the downloaded  .jar package:

Eclipse Add external package
Eclipse Add external package

Also, you can add the package through the project “Properties” menu, in the section “Java Build Path“, in the “Libraries Path“. Press the “Add external JARs…” button to select the downloaded JAR file.

Add external packages to Eclipse Project
Add external packages to Eclipse Project

 

Leave a Reply