Sie sind hier

Installing Java, Maven, and Eclipse

This text was created as an instruction on how to setup a Java programming environment for the practical assignments of the Web Information Retrieval (SS 2016) Lecture. However, it may also be of use to other people.

Java Development Kit (JDK)

Java is only a programming language; if you want to develop, compile, and run programs in Java you need have the Java Development Kit (JDK) installed on your computer. This section will give a short instruction on how to install the JDK on a Windows computer. If you want to install Java on a different operating system, follow the Installation Guide of the Java Programming Wikibook, which is also a good resource should you get stuck with this guide.

First, we have to install the JDK on our computer. To do this, head to the JDK Download Page, accept the license agreement, and download either the Windows x86 or Windows x64 version (depending on your system). Run the executable you downloaded, and follow the step-by-step wizard like you would when installing any other program. Installation might take some time.

Afterwards, we need to set our PATH and JAVA_HOME environment variables to tell the system where we installed the JDK. To do this, open the Run window by pressing the Win+R keys together. Insert the following command with copy-and-paste, and press OK.

rundll32 shell32.dll,Control_RunDLL sysdm.cpl
  1. The System Properties window should open.
  2. Navigate to the Advanced tab on the tob, and select Environment Variables...
  3. Under System variables, select the variable named Path and click Edit...
  4. Append a semicolon (;) followed by your JDK bin folder to the Variable value. On my computer the new value was <old value>;C:\Program Files\Java\jdk1.8.0_77\bin. Of course your old value and JDK path might be different from my system.
  5. Cofirm this change by clicking OK.
  6. Next add a new environment variable by clicking New... under System variables.
  7. Enter JAVA_HOME as the Variable name and your JDK path under Variable value. For me the value was C:\Program Files\Java\jdk1.8.0_77 (note this time withouti the bin-Folder!)
  8. Click OK to all opened dialog windows.

Last, to check if the JDK has been installed successfully, open the Command Prompt (for example by pressing the Win+R keys together, and then typing cmd, followed by Ok) again. Enter the following command:

java -version

You should see an output similar to:

java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Next check what happens when you enter javac -version; your output should be something like javac 1.8.0_77. If you get an error, such as 'java(c)' is not recognized as an internal or external command, operable program or batch file., the installation did not work correctly. If you are sure to have installed the JDK correctly, check that you set your environment variables correctly. If everything worked fine, congratulations, you have successfully installed the Java Development Kit!

Apache Maven

Apache Maven is a build automation tool for Java, i.e. it allows us to build/package our programs, run them, and execute tests. Additionally, it is able to perform dependency management, and thus performs a similar role as npm (Javascript) or pip (Python). This section provides a short installation guide for a Windows system, if you want to install Maven on another operating system, consult the Official Maven Installation Guide. Before installing Maven, make sure you have installed the JDK correctly.

First, download the latest Maven binary archive, extract it, and copy the contained folder apache-maven-3.3.9 to any location of your choice. On my system I chose C:\Program Files\apache-maven-3.3.9.

Afterwards, we need to update our PATH environment variable again. Like above, open the Run window by pressing the Win+R keys together. Insert the following command with copy-and-paste, and press OK.

rundll32 shell32.dll,Control_RunDLL sysdm.cpl
  1. The System Properties tab should open.
  2. Navigate to the Advanced tab on the tob, and select Environment Variables...
  3. Under System variables, select the variable named Path and click Edit...
  4. Append a semicolon (;) followed by your Maven bin folder to the Variable value. On my computer the new value was <old value>;C:\Program Files\apache-maven-3.3.9\bin. Of course your old value and Maven path might be different from my system (also do not overwrite the JDK path we added above!).
  5. Click OK to all opened dialog windows.

Last, to check if Maven has been installed successfully, open the Command Prompt again (for example by pressing the Win+R keys together, and then typing cmd, followed by Ok). Enter the following command:

mvn -v

You should see an output similar to:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: C:\Program Files\apache-maven-3.3.9\bin\..
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_77\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

Eclipse

Eclipse is an integrated development environment (IDE). It provides many convenient functions related to programming in a graphical interface. Of course you may use any other Java IDE of your choice, but we can not answer any questions specific to your IDE. Before installing Eclipse, make sure you have installed the JDK correctly. (If you are a MacOS or Linux user you may prefer to use the package manager of your system, instead of this manual installation.)

To install, simply head to the page of the Eclipse IDE for Java Developers, and download the package appropriate for your system. Extract the downloaded archive, and move the contained eclipse folder to a location of your choice; I chose C:\Program Files\eclipse. Inside of the extract folder, you will find the eclipse.exe executable used to start Eclipse. Since you are hopefully going to use Eclipse often, now might be a good time to add a convenient shortcut to your Desktop.

At first start up, Eclipse asks you to select a workspace location. You can choose any folder you want, I stuck to the default setting.