Open source and free since the 90’s.
Overview
This article contains notes on my personal experience installing and using Eclipse IDE.
Eclipse was originally funded by IBM as open source.
Installation
Chose an edition of Eclipse IDE:
a. The edition working with Web (HTML) is licensed (costs money)
b. The “Standard” edition Homebrew for working with Java is free
c. STS (Spring Tools Suite) edition
NOTE: Predix Dev Tools: Set up a Mac OS X development environment for the older Yosmite (Mac OS 10.10).
b. Standard Edition Homebrew install
The simplest way to install the standard edition of Eclipse is to use Homebrew to eclipse-java:
-
Use brew cask to install GUI programs:
brew install --cask eclipse-java
The response (as of 24 July 2017):
==> Satisfying dependencies ==> Downloading https://www.eclipse.org/downloads/download.php?file=/technology/ ######################################################################## 100.0% ==> Verifying checksum for Cask eclipse-java ==> Installing Cask eclipse-java ==> Moving App 'Eclipse.app' to '/Applications/Eclipse Java.app'. 🍺 eclipse-java was successfully installed!
Remember the name of the app is “Eclipse Java”.
Invoke
-
On a Mac, in a Finder click Go > Applications or click the “rocket ship” icon if you have that at the bar at bottom of the screen.
-
Type the portion of “Eclipse Java” until the icon appears.
Alternately, download the installer from:
https://www.eclipse.org/downloads and add STS components.Add STS
To add STS inside a Standard Eclipse install:
- Help > Eclipse Marketplace and Find: Spring.
- Click Install.
-
In Confirm Selected Features, check all (for AOP, AERI, Roo, etc.) explained later.
Included with STS (Spring Tools Suite) is the developer edition of Pivotal tc Server, the drop-in replacement for Apache Tomcat web server optimized for Spring.
The Spring Insight console, tc Server Developer Edition, provides a graphical real-time view of application performance metrics that lets developers identify and diagnose problems from their desktops.
QUESTION: Can actions inside Eclipse be automated?
Uninstall Homebrew
-
The nice thing about using Homebrew is uninstallation is easy:
brew cask uninstall eclipse-java
Alternately:
c. STS install from spring.io
PROTIP: Use the Homebrew module for the Spring Tools Suite (STS) for Mac.
-
In a Terminal:
brew install --cask sts
The response (as of 29 Feb 2018):
==> Satisfying dependencies ==> Downloading http://download.springsource.com/release/STS/3.9.2.RELEASE/dist/ ######################################################################## 100.0% ==> Verifying checksum for Cask sts ==> Installing Cask sts ==> Moving App 'STS.app' to '/Applications/STS.app'. 🍺 sts was successfully installed!
-
Proceed to First Time Config below.
Alternately:
-
Use a modern internet browser to the STS download page at
https://spring.io/tools/sts/all -
Click on the web page “Based on Eclipse 4.7.0” under “Mac”, then “dmg 397MB”.
-
Click “Save File” in the pop-up if it appears.
-
In the Finder’s Downloads folder, CAUTION: If you see a number to the right of the “sts-bundle” folder name, another installer was downloaded previously. If there is another STS app there, move it to Trash.
-
Expand the installer file just downloaded by clicking it :
spring-tool-suite-3.9.2.RELEASE-e4.7.2-macosx-cocoa-x86_64.dmg
- Drag the green “STS” icon (for the Spring brand) and drop it on the Applications folder (this is a type of manual security requirement Apple imposes to copy into the Applications folder.
-
Close the dialog by clicking the top left-most (red) button.
-
Switch to Finder and click the eject icon for the STS installer under the Devices section.
-
Click Applications if it’s among Favorites or if it’s not:
First time config.
-
Switch to Finder and navigate to the /Applications folder. (select the Go menu and select Applications).
NOTE: The version at time of this writing is dated December 21, 2017.
-
If you will be using the app a lot, drag and drop the STS icon to Apple’s bar at the bottom.
-
Open STS by double-clicking the icon. It may take a minute to load the first time.
-
When you invoke Eclipse for the first time, you may see a “Welcome” screen. If so, at the lower-right of the screen, uncheck “Always show Welcome at start up”.
-
If you get an “Are you sure you want to open it?”, click Open for the Launcher pop-up:
Workspace config.
By default, the folder is something like (where you see your account instead of “wilsonmar”):
/Users/wilsonm/Documents/workspace-sts-3.9.2.RELEASE
-
PROTIP: Change the Workspace to a directory per your personal or your organization’s standards which is under Git source version control.
PROTIP: I like to create under my persoal home directory a folder named “gits” for various projects. Others may prefer “projects” or “dev”.
Under that I create a folder for the account name in GitHub which in my case is “wilsonmar”. If the repository is from someone else, I create a folder (such as “baedlund”).
Under that I let my git client create repository folders cloned from my GitHub account.
PROTIP: STS will create folders that don’t yet exist.
-
Click “Use this as the default and do not ask again”, then the blue Launch button for the Eclipse Dashboard in the middle pane.
-
In the Eclipse Spring Tools Suite menu bar, select File, Switch Workspace, and Other… to change the Workspace folder.
Tutorials
-
Take the time to click “GUIDES” to visit https://spring.io/guides such as
https://spring.io/guides/gs/accessing-twitter
VIDEO: Spring Tips: Spring Tool Suite” by Josh Long is dated Dec 21, 2016 is based 3.8.2.
This video course on Udemy uses STS 3.6.4 under Java JDK 8u45.
Pluralsight.com has a two-part series on Eclipse from 2013 by Tod Gentille (@Tod Gentille) of syncorsystems.com:
On YouTube:
-
Introduction to Eclipse: Driving Java Productivity from 2012
by Marakana
-
Introduction to Eclipse: Driving Java Productivity from 2012
by Marakana
Plug-ins
-
Cargo Maven Plug-in
-
Checkstyle
-
EclEmma - Java Code Coverage for Eclipse
-
Spelling checking
-
Formatter
Preferences
QUESTION: Is there a command line script that does all this automatically?
-
Click Spring Tool Suite - Preferences -
- Expand Java - Expand Code Style - select Formatter - Import - select
the formatter-rest.xml file containing code formatting from the course repository downloaded from
https://github.com/eugenp/REST-With-Spring/blob/module1/eclipse/formatter-rest.xml
- click Apply.
-
Expand XML > expand XML Files > click Editor
- set: Line Width to 180 (from default 72)
- check: Align final bracket in multi-line element tags
- check: Format comments (the default)
- check: Join lines (the default)
- check: Indent using spaces (instead of default tabs)
- set: Indentation size to 3 (instead of 1)
- uncheck: Use inferred grammar in absence of DTD/Schema
- click Apply
-
Expand Web > expand HTML Files > click Editor
- set: Line Width to 180 (from default 72)
- check: Align final bracket in multi-line element tags
- check: Indent using spaces (instead of tabs)
- set: Indentation size to 3 (instead of 1)
- within Inline Elements, select: input
- click: Remove
- uncheck: everything else (from the Formatting section)
- click Apply
-
Click “Review IDE configuration settings” to “Review the IDE’s most fiercely contested preferences”.
- Show line numbers in editor: yes.
- Check spelling
- Execute jobs in background
- Encode text files with UTF-8
- Enable preference recorder
- Click “Apply and Close” to close the Preferences dialog.
The changes above update the settings.properties text file for the environment envTarget. ???
Import Project
A flexible approach to define a single run configuration for an imported project keeps the parent and the working modules separate.
First, import the parent pom.xml and run a build to create the .project file the IDE uses.
- In the Eclipse (Spring Tools Suite)
-
Open your existing workspace in Eclipse STS.
- Choose menu File -> Import…
- If you’re using Maven, select that. Double-click “Existing Maven Project”. Click Next.
- Click Browse… to open Finder to your default workspace.
- Click to navigate to the project folder which contains the pom.xml file Maven reads. Click Open.
- Deselect All.
- Click the checkbox to just the pom.xml file.
-
Type “PARENT” over whatever is under the “Add project(s) to working set” field.
Next, import files specific only to the child module you are actively working on.
- Choose menu File -> Import…
- If you’re using Maven, select that. Double-click “Existing Maven Project”. Click Next.
- Click Browse… to open Finder to your default workspace.
- Click to navigate to the project folder which contains the pom.xml file Maven reads. Click Open.
- Deselect All.
-
Click the checkbox to the common/pom.xml and um-webapp/pom.xml for the module you are working on (starting with lesson 1).
- Type “WORK” under the “Add project(s) to working set” field.
-
Click Finish.
- There should now be three top-level items in the Package Explorer.
### Compile from Eclipse #
-
Click the black arrow icon to the right of the green Run icon.
- Right-Click on “Maven Build”, then “New”.
- In Base directory type in a variable: ${project_loc} so that it points to whatever project is selected in Package Explorer.
- In Goals: clean install
- In User Settings: ???
- Click Apply to save.
- Click Run.
-
Look in the Console pane for “BUILD SUCCESS”.
-
To compile and run your program, keep the “Main” app Java file tab active and
- use Run option available in the Eclipse IDE or
- press Ctrl + F11 to compile and run your MainApp application.
If everything is fine with your application, this will print the following message in Eclipse IDE’s console.
New Project
-
Right-click on the blank part under “Project Explorer” to select “New” and “Other”.
-
In the New Select a Wizard dialog, select “Java Project”, then “Next”.
-
Type your Project Name.
-
It’s best to leave the default JRE version because additional downloads are necessary if you want to change it.
-
Click Finish.
-
Check “Remember” then click “Yes” to associate the project with a perspective.
Notice several JRE System Libraries were added automatically. .jar files are Java classes. .dll files are Windows classes.
Notice the “src” folder is created to hold source code.
-
Right-click the app name to select Package (test suite).
-
Name it “Basics”.
-
Right-click on “Basics”.
-
Type the Name for Java Class, such as “helloworld”.
Perspectives
Perspectives define the size and location of different views on the workspace window.
-
Right-click on the Perspectives icon at the upper-right corner and select “Show Text”.
- Click the icon to the right of the Perspective icon to open a list of perspectives.
- Click Cancel.
Tomcat 8 server
Seeing how source code displays locally is important to not upload bad code into the team repository.
-
Download and unarchive the latest Tomcat 8 distribution.
brew install tomcat
Alternately, install manually using instructions at https://wolfpaulus.com/mac/tomcat/
-
To see where brew stores the formula:
brew –prefix tomcat
The response:
/usr/local/opt/tomcat
Use that in the next step:
- In STS Preferences - expand Server - click Runtime Environment - Add - Apache Tomcat v9 (the latest version).
- Paste “/usr/local/opt/tomcat”.
- Drill down to bin, Catalina. /usr/local/Cellar/tomcat/9.0.5/bin
-
Press Next.
-
Customize server (double click the server in the Servers view) – In the Publishing section - check Never Publish Automatically – In the Timeouts section - set the Start timeout to 90 sec
Add server
- Add the Servers view using a mouse to click menu Window - Show View - Servers.
- Click the link to “create a new server” (or rightclick - New - Server).
- Expand Apache by clicking the icon to its left.
- Choose “Tomcat v9 Server” Runtime Environment defined above.
-
Click Next.
-
Customize server (double click the server in the Servers view) – In the Publishing section - check Never Publish Automatically – In the Timeouts section - set the Start timeout to 90 sec
-
Start from folder “/Library/Tomcat” or /usr/local/opt/tomcat” if brew was used to install:
catalina run
Alternately, use shell scripts:
$ /Library/Tomcat/bin/startup.sh
$ /Library/Tomcat/bin/shutdown.sh
-
Install a tiny freeware app, providing a UI to quickly start/stop Tomcat. It may not say so, but Tomcat Controller works on macOS 10.12 just fine.
http://www.activata.co.uk/tomcatcontroller/
-
In a browser, go to
http://localhost:8080
- Customize server (double click the server in the Servers view) – In the Publishing section - check Never Publish Automatically – In the Timeouts section - set the Start timeout to 90 sec
Shortcuts
To go back to previous edit location: Control+Q
-
Keyboard shortcuts for constructors.
https://www.youtube.com/watch?v=ZUM9jEhLie0
https://www.youtube.com/watch?v=E3hKgb4aLHM
https://www.youtube.com/watch?v=X8Xw7FWw49E