Development Environment Setup

Friday, 27 December 2013, 01:52

Tags: Development Environment Setup Eclipse Maven

Currently most of the development I do is in Java. I use Eclipse as IDE and maven as build tool. In this blog post I will describe the setup of my development environment. The next image gives an overview of the directory structure of the development environment.

For each project the development environment looks like the previous image.

  • Installation-Files: In this directory all used installation files are kept. They are stored just in case they would be needed again in the future.
  • Java: The Java version that is used for development is installed in this folder. Most of the time this is the latest release of the Java SE Development Kit at the time of the setup.
  • Maven: At this location Maven is unzipped.
  • Maven-Repository: This is the local repository used by Maven. All the dependencies and plugins that are downloaded by Maven will be stored in this directory.
  • Eclipse: Eclipse is unzipped at this location. This is mostly the Eclipse IDE for Java EE Developers.
  • Eclipse-Workspace: All the source code of the project will reside in the eclipse workspace directory.
  • Environment:
    • Shortcuts: Contains shortcuts to start eclipse and a command line interface to use maven.
    • environment.bat: This bat file sets all the environment files needed by the used tools and adds some folders with executables to the path.
    • cli.bat: With this bat file a command line interface can be started with all the needed environment variables loaded.
    • eclipse.bat: This bat file will first load all environment variables and then start Eclipse.

In environment.bat all the environment variables needed for the development environment are set as shown in the code snippet below.

  • line 3-7: The directory is changed to location of environment.bat (%~dp0) and then changed to the project root. This project root is saved in the PROJECT_HOME environment variable. Then the directory is changed back to the original directory (pushd and popd).
  • line 9: The JAVA_HOME variable is set to the installation directory of Java. This is necessary to setup Maven and for Eclipse.
  • line 11-12: Next M2_HOME is set to the Maven home directory as required for the Maven setup. M2_LOCAL_REPO is set to the location of the local repository. This environment variable is used in the global maven settings to change the local repository location.
  • line 14-15: Environment variables are also set for the Eclipse and Eclipse workspace directories.
  • line 17: The Java and Maven bin directories are added to the PATH in order to be able to execute the commands from the command line.

cli.bat is displayed in the next snippet. With this file a command line interface for the development environment can be started.

  • line 3-4: The current directory is changed to the location of cli.bat. This is the directory where environment.bat is also located. All the environment variables are loaded and the path is set.
  • line 5-6: The command line is opened in the project home with all the necessary environment variables loaded and the path adapted. All development tools are accessible through the command line interface.

At last there is eclipse.bat which can be used to start eclipse.

  • line 3-4: The current directory is changed to the location of eclipse.bat. This is again the directory where environment.bat is also located. All the environment variables are loaded and the path is set.
  • line 5-6: Eclipse is started with the Eclipse-Workspace directory as workspace. All the environment variables and path adaption are now also available within Eclipse.

One last thing has to be done in Eclipse. The Maven plugin of Eclipse has to be configured to use the Maven installation of the development environment instead of an embedded installation (Window -> Preferences -> Maven -> Installations). This way the global settings are used in which the location of the local repository is changed. Now Eclipse also uses the Maven-Repository directory as its local repository.