Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Instagram Youtube

Github Stackoverflow Pinterest

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:

  1. Use brew cask to install GUI programs:

    brew cask install 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

  2. 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.

  3. 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:

  4. Help > Eclipse Marketplace and Find: Spring.
  5. Click Install.
  6. 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

  7. 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.

  1. In a Terminal:

    brew cask install 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!
    
  2. Proceed to First Time Config below.

Alternately:

  1. Use a modern internet browser to the STS download page at
    https://spring.io/tools/sts/all

  2. Click on the web page “Based on Eclipse 4.7.0” under “Mac”, then “dmg 397MB”.

  3. Click “Save File” in the pop-up if it appears.

  4. 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.

  5. Expand the installer file just downloaded by clicking it :

    spring-tool-suite-3.9.2.RELEASE-e4.7.2-macosx-cocoa-x86_64.dmg

  6. 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.
  7. Close the dialog by clicking the top left-most (red) button.

  8. Switch to Finder and click the eject icon for the STS installer under the Devices section.

  9. Click Applications if it’s among Favorites or if it’s not:

    First time config.

  10. 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.

  11. If you will be using the app a lot, drag and drop the STS icon to Apple’s bar at the bottom.

  12. Open STS by double-clicking the icon. It may take a minute to load the first time.

  13. 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”.

  14. 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

  15. 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.

  16. Click “Use this as the default and do not ask again”, then the blue Launch button for the Eclipse Dashboard in the middle pane.

  17. In the Eclipse Spring Tools Suite menu bar, select File, Switch Workspace, and Other… to change the Workspace folder.

    Tutorials

  18. 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:

Plug-ins

  • Cargo Maven Plug-in

  • Checkstyle

  • EclEmma - Java Code Coverage for Eclipse

  • Spelling checking

  • Formatter

  • Agilefant

Preferences

QUESTION: Is there a command line script that does all this automatically?

  1. Click Spring Tool Suite - Preferences -

  2. 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.
  3. 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

  4. 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

  5. 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

  6. 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.

  1. In the Eclipse (Spring Tools Suite)
  2. Open your existing workspace in Eclipse STS.

  3. Choose menu File -> Import…
  4. If you’re using Maven, select that. Double-click “Existing Maven Project”. Click Next.
  5. Click Browse… to open Finder to your default workspace.
  6. Click to navigate to the project folder which contains the pom.xml file Maven reads. Click Open.
  7. Deselect All.
  8. Click the checkbox to just the pom.xml file.
  9. 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.

  10. Choose menu File -> Import…
  11. If you’re using Maven, select that. Double-click “Existing Maven Project”. Click Next.
  12. Click Browse… to open Finder to your default workspace.
  13. Click to navigate to the project folder which contains the pom.xml file Maven reads. Click Open.
  14. Deselect All.
  15. Click the checkbox to the common/pom.xml and um-webapp/pom.xml for the module you are working on (starting with lesson 1).

  16. Type “WORK” under the “Add project(s) to working set” field.
  17. Click Finish.

  18. There should now be three top-level items in the Package Explorer.

### Compile from Eclipse #

  1. Click the black arrow icon to the right of the green Run icon.

    eclipse-run-config

  2. Right-Click on “Maven Build”, then “New”.
  3. In Base directory type in a variable: ${project_loc} so that it points to whatever project is selected in Package Explorer.
  4. In Goals: clean install
  5. In User Settings: ???
  6. Click Apply to save.
  7. Click Run.
  8. Look in the Console pane for “BUILD SUCCESS”.

  9. 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

  1. Right-click on the blank part under “Project Explorer” to select “New” and “Other”.

  2. In the New Select a Wizard dialog, select “Java Project”, then “Next”.

  3. Type your Project Name.

  4. It’s best to leave the default JRE version because additional downloads are necessary if you want to change it.

  5. Click Finish.

  6. 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.

  7. Right-click the app name to select Package (test suite).

  8. Name it “Basics”.

  9. Right-click on “Basics”.

  10. Type the Name for Java Class, such as “helloworld”.

Perspectives

Perspectives define the size and location of different views on the workspace window.

  1. Right-click on the Perspectives icon at the upper-right corner and select “Show Text”.

  2. Click the icon to the right of the Perspective icon to open a list of perspectives.
  3. Click Cancel.

Tomcat 8 server

Seeing how source code displays locally is important to not upload bad code into the team repository.

  1. Download and unarchive the latest Tomcat 8 distribution.

    brew install tomcat

    Alternately, install manually using instructions at https://wolfpaulus.com/mac/tomcat/

  2. To see where brew stores the formula:

    brew –prefix tomcat

    The response:

    /usr/local/opt/tomcat
    

    Use that in the next step:

  3. In STS Preferences - expand Server - click Runtime Environment - Add - Apache Tomcat v9 (the latest version).
  4. Paste “/usr/local/opt/tomcat”.
  5. Drill down to bin, Catalina. /usr/local/Cellar/tomcat/9.0.5/bin
  6. Press Next.

    eclipse-sts-tomcat-config

  7. 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

  8. Add the Servers view using a mouse to click menu Window - Show View - Servers.
  9. Click the link to “create a new server” (or rightclick - New - Server).
  10. Expand Apache by clicking the icon to its left.
  11. Choose “Tomcat v9 Server” Runtime Environment defined above.
  12. Click Next.

  13. 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

  14. 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

  15. 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/

  16. In a browser, go to

    http://localhost:8080

  17. 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

https://www.youtube.com/watch?v=ZUM9jEhLie0

https://www.youtube.com/watch?v=E3hKgb4aLHM

https://www.youtube.com/watch?v=X8Xw7FWw49E