Java is one of the most commonly used programming languages. Installing Java is straight forward. If you want to develop java applications, you need to install Java SDK and if you want to run applications developed in java, you need to install JRE. You need little more than just Java installation to make your development in Java easier. In this post, we will install the below tools required for application development in Java.
- Java(naturally !!)
- JDK(Java Development Kit)
- JRE(Java Runtime Environment)
- Integrated Development Environment(IDE)
- Build Tools
- Web servers
These are the most commonly used tools in java development and the below blog post has information on where to download these tools, how to install and to check if they are installed and configured correctly.
Java
You can download the latest version of Java SDK from the below oracle site.
www.oracle.com/technetwork/java/javase/downloads/index.htmlClick on ‘Download’ button highlighted in the below screen to download the latest version of Java SDK.
Accept License Agreement to continue to downloads.
Select the OS which you are using and the architecture(32 bit or 64 bit) you want to download. This will start downloading the Java SDK.
The Java SDK downloaded installer will be similar to the below screen shot. It may vary little bit based on Java version , operating system and the architecture.
Double click on the installer to start Java SDK installation process.
After the installation is triggered, click on ‘Next’ to continue the installation.
During the installation process, the below screen will be displayed which provides options for installation. If you want to change the default installation path, click on ‘Change’ and select the location on your hard disk at which you want to install the eclipse. If you don’t want to change the default location or if you are not sure what to do, leave it without changing.
There are options to select/deselect installation of JRE and Java source code. You can choose not to install them but it is recommended to install them, since you cant run the applications you develop without installing JRE. JRE(Java Run Time Environment) is required for running applications developed in Java. Though installing Source Code is not required, it is good to have it installed as you can look up the source code when ever you want to.
Once you are done with the customizations click on ‘Next’ to continue the installation.
Java SDK is installed.
After installing Java SDK, the installer will continue to install JRE also as you selected to install JRE while customizing the Java SDK installation.
You can select the location to install by clicking on ‘Change’ and then choosing the location on hard disk at which you want to install the JRE. Similar to Java SDK, If you don’t want to change the default location or if you not sure about what to do, leave the default location. Click on ‘Next’ to start installing the JRE.
The JRE starts installing.
Click on ‘Close’ to complete the installation. The installation of Java SDK and JRE is completed.
Now there are couple of more steps to make Java work and make it integrate better with other Java development tools.
Right click on ‘Computer’ on your desktop and select ‘Properties’ which displays the below screen. Click on ‘Advanced System settings’.
Click on ‘Environment Variables’ in the below screen.
Clicking on Environment Variables will display the below Window. If you want all the user accounts on your system to use Java, then run the below steps on ‘System variables’ section in the below screen. If you want only the user account with which you logged in to use Java, run the below steps in ‘User variables for YYY’ section. ‘YYY’ needs to replaced with the user account name you logged in with.
Click on ‘New’ button.
Enter the Variable name as ‘JAVA_HOME’.
Enter the Variable value as ‘C:\Program Files\Java\jdk1.8.0’. This will change based on where you installed Java.
Click on ‘OK’ to save the entry.
Now select the ‘Path’ in the list of system variables and click on ‘Edit’ button. When the below screen shows up, add the below text to the existing content in the Variable value.
%JAVA_HOME%\bin;C:\Program Files\Java\jre8\bin
If you are adding this to the end of the existing value, prepend ; to the above text while adding. If you are adding this some where in between the existing content, make sure, you add this after any ; in the existing text and also append ; to the above text while adding. Click on ‘OK’ to save the modifications.
Click on ‘OK’ in the ‘Environment Variables’ and ‘System Properties’ windows to save the modifications. Open the command prompt and run the below command to see if the Maven is working correctly.
Open the command prompt and run the below command to check the Java SDK and JRE installation.
java –version
If the JRE is installed properly, you will see the java version similar to the below screen shot.
Oracle site has information to guide on Java development.
http://docs.oracle.com/javase/8/
IDE
Integrated Development Environment(IDE) is a suite of developer tools which provides all the tools required by developers for developing the applications. These consists of source code editors, compilers, interpreter, debuggers, build tools, code completion features, options to refactor the code, auto generate the classes from templates, UI's for maintaining VCS etc. IDE's maximize the developer productivity since all the above mentioned features are built into one utility and will help the developers to automate several tasks. It is difficult for even seasoned developers to develop applications just using code editors without using an IDE.
One of the reason Java is very popular is due to huge tooling support it has. Java is supported by several Open source and commercial IDE's. The most common open source IDE's include Eclipse and NetBeans while some of the popular commercial IDE's are Myeclipse( built on top of eclipse and so mostly similar but with much wider support and more sophisticated support for more frameworks) and IntelliJ IDEA.
We will install eclipse and NetBeans which are the most popular open source Java IDE's.
Eclipse
Eclipse is free and open source IDE written mostly in Java. By installing various plugins, Eclipse can also be used to develop applications in several other programming languages like C, C++, JavaScript, PHP, Python, Scala, Groovy, Ruby etc part from Java. Eclipse was initially developed by IBM and was open sourced in 2001.Eclipse uses plugins heavily for providing all the functionality and for supporting several frameworks in Java and also support for other programming languages.It can run on Windows, Linux, Solaris and Mac OS X..
Download the latest version of eclipse from the below Eclipse download site.
https://www.eclipse.org/downloads/
You need to select the OS you are using and download the 32 bit or 64 bit version based on the what your system supports. You need to download ‘Eclipse IDE for Java EE Developers’ .Unzip the downloaded eclipse zip folder to a location on your hard disk and launch eclipse by double clicking ‘eclipse.exe’.
Eclipse site has more information on how to use Eclipse.
http://www.eclipse.org/users/
NetBeans
NetBeans is also a open source IDE written in Java and supports C, C++ and PHP development apart from Java. NetBeans was acquired by Sun Microsystems in 1999 and was open sourced in 2000. Similar to eclipse, NetBeans can also run on Windows, Linux, Solaris and Mac OS X. NetBeans supports development of several type of Java applications like Java SE, Java ME, Java FX, Web, EJB and Mobile applications out of box without installing many modules. It also provides support for build tools like Apache Ant, Apache Maven and version control systems like Subversion, Git, Clearcase and Mercurial.
NetBeans can be downloaded from the below site.
https://netbeans.org/downloads/
Since we want to set up Java environment, we can choose to download either Java SE or Java EE version of NetBeans. If you want to develop web applications, you need Java EE version and if you want to develop applications only in Java SE(core java), you can download Java SE version. Java EE version is Java SE Version + capabilities for Java EE apps, so it doesn’t do harm to download this if you are not sure. How ever if you want to develop Java ME apps, you need click the ‘Download’ under ‘All’ column.
NetBeans will start downloading automatically. If it doesn’t, click on ‘download it here’ link the below page.
The downloaded NetBeans installer will be similar to below. The name will vary little bit based on the NetBeans version downloaded and also the flavor of the downloaded NetBeans. Double click on the installer to start installation.
The NetBeans installer is started.
NetBeans installer is initializing, just wait for a moment before next screen for customizing the NetBeans installation shows up.
In the below screen, you can select the application servers you want to install with NetBeans. GlassFish and Tomcat are the servers supported by NetBeans automatically and so select them if you want to install. If you are not sure, just select them as having them installed isn’t going to cause any harm. Then click on ‘Next >’ to continue to the next screen.
You need to accept the license agreement and click on ‘Next >’ to continue installation.
If you want to create JUnit test cases for your application(why not ?), accept the license agreement for installing JUnit and click on ‘Next >’ to continue installation. If you don’t want to install JUnit, you can select ‘Do not install JUnit’ and click on ‘Next >’ button to continue installation.
In the below location, you can select the NetBeans installation location on the hard disk and also the JDK path for the NetBeans to use. The installer provides the default options. If the provided Java SDK path is correct, leave it as it is else click on Browse to select the correct path. If you want to change the NetBeans installation path, click on Browse button against it and navigate to the location where you want to install NetBeans. Click on ‘Next > ‘ to continue installation once you are done with selection of NetBeans Installation directory and Java SDK path.
The below screen will be displayed if you selected to install the GlassFish server. Select the location at which you want to install the GlassFish server and also select the JDK you want the GlassFish server to use. The installer provides the default paths. You can change them if you wish by clicking on ‘Browse’ button and navigating to your preferred directory. Once you are ready, click on ‘Next >’ to continue NetBeans installation.
In the below screen, the installation path of the Tomcat is displayed. You can change it by clicking on ‘Browse’ button and navigating to the preferred directory if you wish to, else leave it to default location suggested by the Installer. Click on ‘Next > ‘ to continue the installation.
The below screen displays the summary of the installation locations you selected on all the previous screens. If you want to change any of those, you can click on ‘Back’ and make the required modifications. Click on ‘Install’ to start installation of NetBeans.
The installer starts installing the NetBeans IDE. It will take some time to complete the installation as the installation is more than 600 MB.
Still installing….
Installing updates and JUnit.
The installation of NetBeans IDE is completed. Click on ‘Finish’ to close the Window.
Double click on the NetBeans shortcut on the desktop to launch NetBeans.
More information on using NetBeans is available the NetBeans site provided below.
https://netbeans.org/kb/index.html
Apache Maven
Apache Maven is a open source build automation tool written in Java. Maven has description on how a software is build and its dependencies. Maven can be used to build and manage projects written in C#, Ruby and Scala etc. Maven uses Project Object Model(POM) for maintaining the projects. Since this was written in Java, this also requires Java to be installed on the system.
Download the latest version of Apache Maven from the below site.
http://maven.apache.org/download.cgi
Click on apache-maven-3.2.2-bin.zip. The file name may vary a little bit based on version you are downloading.
The downloaded maven zip file will look similar. Since the file name contains the version number, the file name may change based on the version of Maven you downloaded.
Extract maven to your preferred location on your hard disk. The extracted location will be Maven Home location. ex: I have extracted Maven to ‘C:\software\apache-maven-3.2.2’ and so ‘C:\software\apache-maven-3.2.2’ will be maven home location on my system.
Since we are done with the extraction of maven, let us check if we can run maven commands and execute them successfully. Run the below command to check if Maven is working correctly.
mvn –version
Looks like maven is still not working correctly. We have extracted maven , but we didn’t do the necessary configurations for OS to recognize the maven commands. We still need to do a couple of configurations to run maven without any issues.
Right click on ‘Computer’ on your desktop and select ‘Properties’ which displays the below screen. Click on ‘Advanced System settings’.
Click on ‘Environment Variables’ in the below screen.
Clicking on Environment Variables will display the below Window. If you want all the user accounts on your system to use Maven, then run the below steps on ‘System variables’ section in the below screen. If you want only the user account with which you logged in to use Maven, run the below steps in ‘User variables for YYY’ section. ‘YYY’ needs to replaced with the user account name you logged in with.
Click on ‘New’ button.
Enter the Variable name as ‘M2_HOME’.
Enter the Variable value as ‘C:\software\apache-maven-3.2.2’. This will change based on where you extracted the Maven.
Click on ‘OK’ to save the entry.
Now select the ‘Path’ in the list of system variables and click on ‘Edit’ button. When the below screen shows up, add the below text to the existing content in the Variable value.
%M2_HOME%\bin
If you are adding this to the end of the existing value, prepend ; to the above text while adding. If you are adding this some where in between the existing content, make sure, you add this after any ; in the existing text and also append ; to the above text while adding. Click on ‘OK’ to save the modifications.
Click on ‘OK’ in the ‘Environment Variables’ and ‘System Properties’ windows to save the modifications. Open the command prompt and run the below command to see if the Maven is working correctly.
mvn --version
You can see the version of maven that is installed, maven home and the java version used and other system details. These may vary based on Maven, Java versions used and also based on your system specifics.
More information on Maven is available at the below site.
http://maven.apache.org/run-maven/index.html
Apache Ant
Apache Ant(Another Neat Tool) is an open source java tool for automating the software build process. It was developed to build Apache Tomcat and was released as an stand alone Apache tool on July 19, 2000. It uses XML for describing the build process and its dependencies. Similar to Java this is cross platform and can run on any OS supported by Java. Since this is developed in Java, this requires Java installation to work.
Apache Ant can be downloaded from the below site.
http://ant.apache.org/bindownload.cgi
Download the latest version of Ant Zip archive(highlighted in Green) from the downloads page.
The download Ant zip archive will look similar. The name may vary a little bit based on the version of Ant downloaded.Extract it to your preferred location on the hard disk.
The extracted Ant installation will look similar to below. There is no installation for Ant and the location to which the Ant is extracted is your Ant home location. Since I have extracted Ant to ‘C:\software\apache-ant-1.9.4’, that location is my Ant’s home.
Now let us open the command prompt and run the below command to see if Ant is working correctly.
ant -version
As you can see, ant is not working. There is nothing work with the installation. We just extracted the Ant, but the OS still doesn’t know any thing about Ant.
You need to make a couple of configurations for your system to recognize Ant installation. You need to define ANT_HOME and add Ant executable to the Path, so that OS will recognize the Ant commands whenever you run them. Right click on ‘Computer’ on your desktop and select ‘Properties’ which displays the below screen. Click on ‘Advanced System settings’.
Click on ‘Environment Variables’ in the below screen.
Clicking on Environment Variables will display the below Window. If you want all the user accounts on your system to use Ant, then run the below steps on ‘System variables’ section in the below screen. If you want only the user account with which you logged in to use Ant, run the below steps in ‘User variables for YYY’ section. ‘YYY’ needs to replaced with the user account name you logged in with.
Click on ‘New’ button.
Enter the Variable name as ‘ANT_HOME’.
Enter the Variable value as ‘C:\software\apache-ant-1.9.4’. This will change based on where you extracted the Ant.
Click on ‘OK’ to save the entry.
Now select the ‘Path’ in the list of system variables and click on ‘Edit’ button. When the below screen shows up, add the below text to the existing content in the Variable value.
%ANT_HOME%\bin
If you are adding this to the end of the existing value, prepend ; to the above text while adding. If you are adding this some where in between the existing content, make sure, you add this after any ; in the existing text and also append ; to the above text while adding. Click on ‘OK’ to save the modifications.
Click on ‘OK’ in the ‘Environment Variables’ and ‘System Properties’ windows to save the modifications. Open the command prompt and run the below command to see if the Ant is working correctly.
ant -version
The output displayed should look similar to above with differences in the version and the compiled date due to difference in the Ant version installed.
More information on Apache Ant is available at the below site.
http://ant.apache.org/manual/index.html
Apache Tomcat
Apache Tomcat is an open source web server and servlet container. It is one of most commonly used web containers running several millions of Java web applications across the world. It has support for clustering and High availability.
The latest version of Tomcat can be downloaded from the below site.
http://tomcat.apache.org/download-80.cgi
There are multiple options to download. If you want to run Tomcat as a service on your system, You need to download ‘32-bit/64-bit Windows Service Installer’. If you want to run Tomcat as a batch application, you can download 32-bit Windows.zip or 64-bit Windows.zip based on operating system you have and the architecture of Java you installed.
First we will install the Tomcat in service mode and later we will install it to run in batch mode. So click on ‘32-bit/64-bit Windows Service Installer’ to download the Windows installer. The downloaded executable should look similar while file name can vary a little bit based on the version of Tomcat downloaded. Double click on the executable to start the installation.
Click on ‘Next >’ button to continue the installation.
Click on ‘I Agree’ to agree the license agreement and to continue the installation.
The below screen has option to select the ‘Type of Installation’. By default, ‘Normal’ is selected.
You can select any of the other options available like ‘Full’. Based on the selection, the options below the installation type will be selected/deselected indicating which components will be installed or not installed. Click on ‘Next >’ to continue installation.
You can configure the Tomcat ports and provide the manager user name and password to manage the Tomcat remotely through web.
By default Tomcat runs on 8080 port in development environment and unless you have some other application running on that port , you need not change it.
You can provide a service name with which you want to view the Tomcat in Windows Services.
Also provide the admin and manager user name and password.You can remove any of these roles or all these roles in the ‘Roles’ textbox if you don’t want them on the Tomcat installation. Click on ‘Next >’ to continue the installation.
Configure the path of JRE you want this Tomcat installation to use and click on ‘Next > ‘ to continue installation.
Configure the location at which you want to install Tomcat and click on ‘Install’.
Installing Tomcat…
The Tomcat is installed on your system. Click on ‘Finish’ to complete the installation and launch the Tomcat.
Tomcat is launching.
A similar icon to the one highlighted below will be displayed on the task manager.
To check if the Tomcat is installed properly, open the browser and type in the below url.
http://localhost:8080
If you changed the port number while installing Tomcat , you should use that instead of 8080.
If the Tomcat is installed properly, you should see a similar page.
You can start and stop Tomcat from the Windows services. From the Windows home, in Run, type ‘services.msc’ and select ‘services.msc’ from the list. It will show the Windows Services.
The tomcat is installed with the service name you provided while installing. You can click on ‘Stop’ to stop Tomcat and on ‘Restart’ to stop and start the Tomcat(usually for reloading the apps after modifications) and ‘Start’ to start the Tomcat.
Alternatively, you can look up for ‘Apache Tomcat 8.0 Tomcat8’ in your programs and select ‘Configure Tomcat’ which will display the below Window.
In this window, you can stop, start, pause and restart the Tomcat. You can also change the startup type. If it set to automatic, it will be started immediately after the system is started and will be running in the back ground all the time. If it is set to Manual, you need to start it whenever you need it.
In the Java tab of the same window, you can view the Java properties of the Tomcat. You can change the JRE, if required. Also you can change the heap settings by setting the heap options in Java Options. All the normal Java options(GC algorithm, heap size etc) can be set in the Java Options.
Now we will install the Tomcat as a batch application. But it is easier to install the Tomcat as a service and also managing the Tomcat as a service is easier for starters than maintaining it as a batch application.
Click on 32-bit Windows.zip or 64-bit Windows.zip based on your system architecture to download the Tomcat.
The downloaded zip will be similar with slight variation in the name due to the Tomcat version downloaded. Extract the zip to your preferred location on your hard disk.
The extracted Tomcat folder will be similar to this.
To launch the Tomcat, go to ‘bin’ directory inside the Tomcat installation and double click on ‘startup.bat’.
The Tomcat will be launched in the command prompt.
Similar to service mode, type the below link in the browser to check if Tomcat is installed and launched properly.
http://localhost:8080/
If installed and started correctly, you will seen the below local host home page.
If you observe, we didn’t provide any options for JRE or ports like we did in the service mode. Obviously Tomcat used the system default JRE and also used the default port in this case. Also we don’t have the Tomcat properties Window where we had options to start, stop, pause and restart tomcat and also configure several Java options. Some of these options are not available and some options like JRE, ports etc needs to be configured in the xml files available in the ‘Conf’ folder of the Tomcat installation directory.So unless there is some thing preventing you from installing Tomcat in service mode, run Tomcat in service mode.
More information on Tomcat is available at the below site.
http://tomcat.apache.org/tomcat-8.0-doc/index.html
Conclusion
We installed the required tools for Java development. It many look little bit over whelming looking at the number of tools installed, but it is not required for every one to have all these tools installed. You may choose to use only some of these, like between eclipse and NetBeans, you may use one IDE you are comfortable with. Similar with the build tools and web server. Based on the type of applications you are using, you may not need a web server at all. Or you can still make the applications work without using any build tool or any IDE. All of these just increase developers productivity once they are mastered. So just don’t get lost or stop looking at these huge list of tools required. Once you know how to write Java programs, you will understand the advantage of using an IDE and similarly once you start creating projects you will understand the need for build tools.Start taking it step by step !