- Spring DI Tutorial
- Spring DI - Home
- Spring DI - Overview
- Spring DI - Environment Setup
- Spring DI - IOC Containers
- Spring Dependency Injection
- Spring DI - Create Project
- Constructor Based Injection Examples
- Spring DI - Constructor Based
- Spring DI - Inner Beans Constructor
- Spring DI - Collections Constructor
- Spring DI - Collection Ref Constructor
- Spring DI - Map Constructor
- Spring DI - Map Ref Constructor
- Setter Based Injection Examples
- Spring DI - Setter Based
- Spring DI - Inner Beans Setter
- Spring DI - Collections Setter
- Spring DI - Collection Ref Setter
- Spring DI - Map Setter
- Spring DI - Map Ref Setter
- Autowiring Examples
- Spring DI - Autowiring
- Spring DI - Autowiring ByName
- Spring DI - Autowiring ByType
- Spring DI - Autowiring Constructor
- Factory Method
- Spring DI - Static Factory
- Spring DI - Non-Static Factory
- Spring DI Useful Resources
- Spring DI - Quick Guide
- Spring DI - Useful Resources
- Spring DI - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Spring DI - Environment Setup
This chapter will guide you on how to prepare a development environment to start your work with Spring Framework. It will also teach you how to set up JDK, Maven and Eclipse on your machine before you set up Spring Framework −
Setup Java Development Kit (JDK)
You can download the latest version of SDK from Oracle's Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
If you are running Windows and have installed the JDK in C:\jdk-11.0.11, you would have to put the following line in your C:\autoexec.bat file.
set PATH=C:\jdk-11.0.11;%PATH% set JAVA_HOME=C:\jdk-11.0.11
Alternatively, on Windows NT/2000/XP, you will have to right-click on My Computer, select Properties → Advanced → Environment Variables. Then, you will have to update the PATH value and click the OK button.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk-11.0.11 and you use the C shell, you will have to put the following into your .cshrc file.
setenv PATH /usr/local/jdk-11.0.11/bin:$PATH setenv JAVA_HOME /usr/local/jdk-11.0.11
Alternatively, if you use an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, you will have to compile and run a simple program to confirm that the IDE knows where you have installed Java. Otherwise, you will have to carry out a proper setup as given in the document of the IDE.
Setup Eclipse IDE
All the examples in this tutorial have been written using Eclipse IDE. So we would suggest you should have the latest version of Eclipse installed on your machine.
To install Eclipse IDE, download the latest Eclipse binaries from www.eclipse.org/downloads. Once you download the installation, unpack the binary distribution into a convenient location. For example, in C:\eclipse on Windows, or /usr/local/eclipse on Linux/Unix and finally set PATH variable appropriately.
Eclipse can be started by executing the following commands on Windows machine, or you can simply double-click on eclipse.exe
Eclipse can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine −
After a successful startup, if everything is fine then it should display the following result −
In this tutorial, we are using maven to run and build the spring based examples. Follow the Maven - Environment Setup to install maven.