Google Guice 3

Google Guice (pronounced as “juice”) is a lightweight dependency injection framework for Java 5 and above. Dependency injection is a design pattern whose core principle is to separate behavior from dependency resolution. Guice allows implementation classes to be bound programmatically to an interface. Refer.

  • Prerequisite

Java must be installed first. For Google Guice 3 Eclipse plugin refer to this link. And for building the application you will need to install Maven. The Google Guice version used is 3.0 and an Eclipse version used is Eclipse Juno v4.2.

  • Google Guice 3 Hello World Program
  1. Once the JDK and Maven setup is done, create a directory in C drive. This will be your workspace with eclipse to write Google Guice code. Create a new Maven project with Eclipse. Refer. Specify details for HelloGuice Project.

    HelloGuice Maven Project

  2. The HelloGuice will be created in Eclipse and it will have /src/main/java/ folder for writing java source.

    Find the Source Code on GitHub: Google Guice 3 for HelloGuice Application.

    Once the code is checkout from GitHub and added into Eclipse, the project structure should look like below screenshot.

    HelloGuice Project Structure

    Now, run the Maven command from this Project folder to build the project, mvn clean install.

    And then, run the HelloGuice program by executing the Main class, HelloGuice3 which has the Main method. This will give you the result on a console as below.

    HelloGuice Console Result

    So here we are done with the first Hello Guice program with Google Guice 3.


One thought on “Google Guice 3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.