Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SPRING COOKBOOK

You're reading from   SPRING COOKBOOK Over 100 hands-on recipes to build Spring web applications easily and efficiently

Arrow left icon
Product type Paperback
Published in May 2015
Publisher Packt
ISBN-13 9781783985807
Length 234 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Murat Yilmaz Murat Yilmaz
Author Profile Icon Murat Yilmaz
Murat Yilmaz
Jerome Jaglale Jerome Jaglale
Author Profile Icon Jerome Jaglale
Jerome Jaglale
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Creating a Spring Application FREE CHAPTER 2. Defining Beans and Using Dependency Injection 3. Using Controllers and Views 4. Querying a Database 5. Using Forms 6. Managing Security 7. Unit Testing 8. Running Batch Jobs 9. Handling Mobiles and Tablets 10. Connecting to Facebook and Twitter 11. Using the Java RMI, HTTP Invoker, Hessian, and REST 12. Using Aspect-oriented Programming Index

Installing Java, Maven, Tomcat, and Eclipse on Mac OS

We will first install Java 8 because it's not installed by default on Mac OS 10.9 or higher version. Then, we will install Maven 3, a build tool similar to Ant, to manage the external Java libraries that we will use (Spring, Hibernate, and so on). Maven 3 also compiles source files and generates JAR and WAR files. We will also install Tomcat 8, a popular web server for Java web applications, which we will use throughout this book. JBoss, Jetty, GlassFish, or WebSphere could be used instead. Finally, we will install the Eclipse IDE, but you could also use NetBeans, IntelliJ IDEA, and so on.

How to do it…

Install Java first, then Maven, Tomcat, and Eclipse.

Installing Java

  1. Download Java from the Oracle website http://oracle.com. In the Java SE downloads section, choose the Java SE 8 SDK. Select Accept the License Agreement and download the Mac OS X x64 package. The direct link to the page is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.
    Installing Java
  2. Open the downloaded file, launch it, and complete the installation.
  3. In your ~/.bash_profile file, set the JAVA_HOME environment variable. Change jdk1.8.0_40.jdk to the actual folder name on your system (this depends on the version of Java you are using, which is updated regularly):
    export JAVA_HOME="/Library/Java/JavaVirtualMachines/ jdk1.8.0_40.jdk/Contents/Home"
  4. Open a new terminal and test whether it's working:
    $ java -version
    java version "1.8.0_40"
    Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
    Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
    

Installing Maven

  1. Download Maven from the Apache website http://maven.apache.org/download.cgi. Choose the Binary zip file of the current stable version:
    Installing Maven
  2. Uncompress the downloaded file and move the extracted folder to a convenient location (for example, ~/bin).
  3. In your ~/.bash_profile file, add a MAVEN HOME environment variable pointing to that folder. For example:
    export MAVEN_HOME=~/bin/apache-maven-3.3.1
  4. Add the bin subfolder to your PATH environment variable:
    export PATH=$PATH:$MAVEN_HOME/bin
  5. Open a new terminal and test whether it's working:
    $ mvn –v
    Apache Maven 3.3.1 (12a6b3...
    Maven home: /Users/jerome/bin/apache-maven-3.3.1
    Java version: 1.8.0_40, vendor: Oracle Corporation
    Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_...
    Default locale: en_US, platform encoding: UTF-8
    OS name: "mac os x", version: "10.9.5", arch... …
    

Installing Tomcat

  1. Download Tomcat from the Apache website http://tomcat.apache.org/download-80.cgi and choose the Core binary distribution.
    Installing Tomcat
  2. Uncompress the downloaded file and move the extracted folder to a convenient location (for example, ~/bin).
  3. Make the scripts in the bin subfolder executable:
    chmod +x bin/*.sh
  4. Launch Tomcat using the catalina.sh script:
    $ bin/catalina.sh run
    Using CATALINA_BASE:   /Users/jerome/bin/apache-tomcat-7.0.54
    ...
    INFO: Server startup in 852 ms
    
  5. Tomcat runs on the 8080 port by default. In a web browser, go to http://localhost:8080/ to check whether it's working.

Installing Eclipse

  1. Download Eclipse from http://www.eclipse.org/downloads/. Choose the Mac OS X 64 Bit version of Eclipse IDE for Java EE Developers.
    Installing Eclipse
  2. Uncompress the downloaded file and move the extracted folder to a convenient location (for example, ~/bin).
  3. Launch Eclipse by executing the eclipse binary:
    ./eclipse

There's more…

Tomcat can be run as a background process using these two scripts:

bin/startup.sh
bin/shutdown.sh

On a development machine, it's convenient to put Tomcat's folder somewhere in the home directory (for example, ~/bin) so that its contents can be updated without root privileges.

You have been reading a chapter from
SPRING COOKBOOK
Published in: May 2015
Publisher: Packt
ISBN-13: 9781783985807
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image