Thursday, May 10, 2018
Quartz Scheduler Introduction
Friday, March 3, 2017
Using Cordova Network API in gwt phonegap
The Network API provides access to the network connectivity information of the device, including wifi and cellular connection status.
Configuration
cordova plugin add cordova-plugin-network-information
The network API can be accessed in gwt phonegap project as described below.
final PhoneGap phoneGap = GWT.create(PhoneGap.class);
Connection connection = phoneGap.getConnection();
The Network API is a very simple API and provides only 1 property/method and 2 events.
Usage
connection.type
Description
This provides the type of active network connection available. The possible connection types are :
- Connection.UNKNOWN
- Connection.ETHERNET
- Connection.WIFI
- Connection.CELL_2G
- Connection.CELL_3G
- Connection.CELL_4G
- Connection.CELL
- Connection.NONE
If the device doesn’t have a active network connection, then the connection type returned is NONE.
If the device has a active Wifi connection and a active 3G/2G/4G connection, then the connection type returned will be Wifi. The devices are designed to use the most efficient network when multiple active networks are available. Since the wifi is more efficient(more reliable, stable and cost effective), the devices normally use wifi even if other cellular connection types are available. If wifi is not available, then the device will check for the next efficient cellular connection type which normally will be in the sequence 4G,3G ,2G and CELL.
Sometimes, it is just not enough to known whether the device has active network connection or not. The application needs to know what is the connection type. You may have a user preference where user decides if the app can work on Cellular network or not. In this case, you need to check the connection type to match the user preference and allow the app to work in offline or not allow the user to launch if the connection type doesn’t match the user preference.
Code
String connectionType = connection.getType();
Supported Platforms
- iOS
- Android
- Windows : When running on a emulator, the connection type is ETHERNET.
offline
Description
This event is fired when the device connected to the network is disconnected.
Code
The code for registering the offline event is below.
phoneGap.getEvent().getOffLineHandler().addOfflineHandler(new OffLineHandler() {
@Override
public void onOffLine(OffLineEvent event) {
//Add your code here.
}
});
online
Description
This event is fired when the device is connected to the network.
Code
The code for registering the online event is below.
phoneGap.getEvent().getOnlineHandler().addOnlineHandler(new OnlineHandler() {
@Override
public void onOnlineEvent(OnlineEvent event) {
//Add your code here.
}
});
Demo
The below example demonstrates usage of the Network API.
public class ConnectionDemo implements EntryPoint {
private Logger log = Logger.getLogger(getClass().getName());
private ScrollPanel scrollPanel = null;
private LinkedList<String> list = null;
private CellList<String> cellList = null;
private Connection connection = null;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
Window.alert("uncaught: " + e.getLocalizedMessage());
Window.alert(e.getMessage());
log.log(Level.SEVERE, "uncaught exception", e);
}
});
final PhoneGap phoneGap = GWT.create(PhoneGap.class);
phoneGap.addHandler(new PhoneGapAvailableHandler() {
@Override
public void onPhoneGapAvailable(PhoneGapAvailableEvent event) {
createUI(phoneGap);
}
});
phoneGap.addHandler(new PhoneGapTimeoutHandler() {
@Override
public void onPhoneGapTimeout(PhoneGapTimeoutEvent event) {
Window.alert("can not load phonegap");
}
});
phoneGap.initializePhoneGap();
}
private void createUI(final PhoneGap phoneGap) {
try {
scrollPanel = new ScrollPanel();
list = new LinkedList<String>();
BasicCell<String> cell = new BasicCell<String>() {
@Override
public String getDisplayString(String model) {
return model;
}
};
cellList = new CellList<String>(cell);
scrollPanel.add(cellList);
connection = phoneGap.getConnection();
addInfo("Connection Type : ");
phoneGap.getEvent().getOnlineHandler().addOnlineHandler(new OnlineHandler() {
@Override
public void onOnlineEvent(OnlineEvent event) {
addInfo("online and connection Type : ");
}
});
phoneGap.getEvent().getOffLineHandler().addOfflineHandler(new OffLineHandler() {
@Override
public void onOffLine(OffLineEvent event) {
addInfo("Offline and connection Type : ");
}
});
RootPanel.get("ConnectionDemo").add(scrollPanel);
} catch (Exception e) {
e.printStackTrace();
}
}
private void addInfo(String type) {
list.add(type+connection.getType());
cellList.render(list);
scrollPanel.refresh();
}
}
Test
For testing, I will run this app in both iPhone 6 and Nexus 6P devices. The test steps are below.
- The app is launched when the device is connected to wifi and there is no cellular connectivity.
- Then the wifi is disabled and since there is no cellular connectivity, the device is in offline mode.
- The wifi is enabled.
- The wifi is again disabled.
- The cellular connectivity is enabled.
- The cellular connectivity is disabled.
Android Device

iOS Device

The code is available on the github.
Tuesday, July 15, 2014
Setting up development environment for GWT
Introduction
This is part of series intended to develop cross platform mobile applications in Java. In this blog post we will see what GWT is and set up the development environment for GWT.GWT is an open source development toolkit for developing complex browser based Ajax applications. Using GWT you can develop Rich Internet Applications(RIA) in Java which is then compiled into JavaScript and is cross browser compliant.
Some of the advantages of developing web applications in GWT are:
Since GWT apps can be developed in Java, you can enjoy all the advantages of developing in Java like auto-complete,Debugging, refactoring, code reuse, polymorphism, over riding, over loading. And Java has large set of tools for development like Eclipse, NetBeans,JUnit and Maven etc which you can use for developing Rich Internet Applications(RIA).
Maintaining large JavaScript projects is not easier when compared to Java projects. But you need JavaScript to run Rich Internet Applications in browser. GWT combines both the advantages. You develop the applications in Java and then they are compiled into JavaScript, so you are having best of both.
GWT is almost similar to AWT and Swing packages in Java and so has a low learning curve for Java Developers.
Supporting several browsers in the market is a difficult tasks. Each browser creates it own set of problems. GWT solves this problem by creating optimized JavaScript code for each browser specifically addressing the issues with that browser. So you can support almost all the major browsers including Android , iPad and iPhone based browsers without worrying about quirks for each browser.
Developing UI's in Java is difficult task compared to other aspects of Java programming. GWT solves it by providing several UI widgets and also you can extend the existing widgets and create your own custom widgets if you wish to.
Some of the limitations of GWT are:
Since the java code is compiled into JavaScript which runs on the browsers, the JavaScript needs to be enabled on the browsers. The applications will not work if the JavaScript is not enabled on the browser.
If you have specialist UI designers who can create HTML pages, this will not work. You may have to implement what ever Designer created again in GWT.
Web Pages created by GWT cannot be indexed by search engines since these applications are generated dynamically.
I think except the second drawback in the list, others don't matter much. It is difficult to provide a rich internet application just in HTML. You will need JavaScript to create rich internet applications. Some apps provide a limited version of apps which work if JavaScript is disabled but majority of apps require JavaScript , so you are not the one there. And there is no reason why large number of users will disable JavaScript on their browsers.
And there is a work around for indexing by search engines. The index page can be created in html, and the remaining pages can be created in GWT. GWT provides an option to define index page in html format. So the index page can still be indexed by search engines and the other pages are mostly dynamically created data, so they don't need to come up in the search unless you they are some kind of content management systems(CMS).
Like the case with all the frameworks, GWT doesn't solve all the issues, but it surely makes the java developers more productive developing the web applications, provides cross browser support and works perfectly for complex enterprise web applications.
GWT Development Environment Setup
We will start setting up the development environment for GWT applications.Java
Since you will developing the applications in Java before they are compiled into JavaScript, you need to set up Java development environment.Once Java environment is set up, let us configure the environment for GWT.
GWT SDK:
Download the latest version of GWT SDK from the GWT project site.
http://www.gwtproject.org/download.html
Go to the above link and click on ‘Download GWT SDK’ highlighted in the above screen. Then unzip the downloaded GWT SDK to your preferred location on your hard disk and it will look similar to the below screen shot.
You might want to add this path to use the commands available in gwt.
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. Select ‘Path’ from the list of available variables and add the path to which you extracted GWT SDK.
Then click on ‘OK’ to close the ‘Edit User Variable’ screen and ‘OK’ in ‘Environment Variables’ and ‘System Properties’ window to save the modifications.
Eclipse
You need to install the eclipse plug-in for GWT to develop GWT applications on eclipse easily. To install GWT eclipse plug-in , launch eclipse , go to Help –> Eclipse Marketplace

Search for GWT in the eclipse market place.

Find out ‘Google Plugin for Eclipse’ and the version number should match the version of the eclipse you are using. If you are using Eclipse Kepler(eclipse 4.3), you need to look for ‘Google Plugin for Eclipse 4.3) and click on ‘Install’.

Accept the license and click on ‘Next’ to continue installation.

It takes some time to download and install the plug-in.

While installing you will get a security warning. Just click on ‘Ok’ to continue the installation.

Restart the eclipse after the installation of plug-in is completed. After restarting the eclipse, you will see the GWT plug-in added to the eclipse tool bar.

NetBeans
If NetBeans is your preferred IDE, there is an GWT plug-in available for NetBeans as well.Launch NetBeans, and in NetBeans ‘Start Page’ click on ‘Install Plugins’.

Alternatively you can navigate to Plugins view by selecting Tools – > Plugins from the NetBeans menu.

In the Plugins Windows, navigate to ‘Available Plugins’ tab.

In the Search textbox, enter gwt and hit Enter. This will return the gwt related plugins for NetBeans.

The GWT plug-in for NetBeans in GWT4NB which is the only GWT plug-in available in the list. So select it to install and click on Install button at the bottom of the Plugins screen.

Click on ‘Next >’ button to start the installation of the GWT NetBeans plug-in.

Select the check box against the license agreement and click on Install to agree to the license agreement and to start the installation process.

GWT NetBeans plug-in is being installed..

When the below message is displayed, just click on Continue to continue the installation process.

Restart the IDE once the installation is completed by selecting against the ‘Restart IDE Now’ and clicking on ‘Finish’.

Once the IDE is restarted, from the NetBeans Menu bar , select File –> New Project. You will see the below New Project window which has a GWT option under the Categories indicating that the GWT Plugin for NetBeans is installed successfully.

Browser Plugins
And we need to install extensions to the browser you are planning to use for running the GWT app in development mode. We will see later what the development mode is, but for now let us install the plugins for the browser to complete our set up of the development environment. If you launch the app in Dev mode without installing the plug-in, the browser will display a message similar to below.
In Internet Explorer:

On Chrome:

When you click on Download, On Chrome, you will be redirected to the Chrome extensions page from where you can install the GWT Developer plug-in.

Click on ‘FREE’ button to install the plug-in on Chrome browser.
On IE, clicking on ‘Download’ button will download a ‘GWTDevPluginSetup.exe’ set up and launching it will install the GWT developer plug-in for IE.
Restart the browsers after the GWT developer plug-in is installed.
Unfortunately the latest versions of Mozilla Firefox doesn't support the GWT Developer Plugin. So you can’t work in Development mode on latest version of Firefox, but GWT already provides a super dev mode which doesn’t require installing any plug-in during development. So you can use Firefox in super dev mode during development mode.
Conclusion
We completed setting up the required development environment for developing applications in GWT. We can start creating GWT applications !!Monday, July 14, 2014
Installing Java on Windows
- Java(naturally !!)
- JDK(Java Development Kit)
- JRE(Java Runtime Environment)
- Integrated Development Environment(IDE)
- Eclipse
- NetBeans
- Build Tools
- Apache Ant
- Apache Maven
- Web servers
- Apache Tomcat
Java
You can download the latest version of Java SDK from the below oracle site.
www.oracle.com/technetwork/java/javase/downloads/index.html
Click 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.

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