How To Change Default Port number of Tomcat Server?
Tomcat by default runs on port number 8080, but many times other Java application also uses 8080 and starting tomcat may result in java.net.BindException. In order to avoid this exception you can change default port of tomcat from 8080 to some other port
Do read
What is a Memory Leak and Garbage Collector in java?
Java Heap Dump Analysis using Eclipse Memory Analyzer (MAT)
How to find the JDK target version from a .class file?
Steps in changing the Tomcat Port
Go to the installation directory of Tomcat Server and then open folder named “conf” and locate the file server.xml and Search for the entry shown bellow:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Change the value of attribute port to your desire value and restart the Tomcat Server.
<Connector port="8089" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Read More
How to increase JVM heap size in Eclipse
To avoid getting java.lang.OutOfMemoryErrors, while running web application, we should increase heap size allocated by the JVM by using command line options.
-Xms<size> set initial Java heap size -Xmx<size> set maximum Java heap size -Xss<size> set java thread stack size
To do this, follow these steps:
1. Open the Server Configuration in Eclipse by double-clicking on the Server instance.
2. Click on “Open launch configuration” link
3. Click on the Arguments tab and add the following command at the end of VM arguments: -Xms128m –Xmx1024m.
These values may vary, depending on requirement/available memory
If you are not using any server, you can type the following on the command line before you run your program:
java -Xms64m -Xmx1024m MyProgram
Note:
- Do not set -Xmx to too small value
- Set -Xms to a small value
Setting -Xmx to small value mostly leads to OutOfMemoryErrors, because this is the maximum amount of memory you are allocating for Java and it cannot utilize memory beyond the set value.
Also If you set -Xms to higher value you might run out of memory. So try to keep it to a small value like -Xms16m.
How to install Eclipse IDE and configure apache tomcat
Downloading Eclipse
If you need to install Eclipse, you can download it from this location: http://www.eclipse.org/downloads/
Installing Eclipse
Once downloaded extract the files in the desired directory. When you extract the file, it creates a sub directory called “eclipse” in which you can find the eclipse.exe application. You can double click on this to launch Eclipse.
Setup Apache Tomcat :
You can download the latest version of Tomcat from http://tomcat.apache.org/. Once you downloaded the installation, unpack the file into a desired directory. For example in D:\Study\Java\apache-tomcat-7.0.23
Now open Eclipse IDE and make sure you are in Java EE perspective; Now right click -> New -> Server in “Servers” area.
Now you could see list of servers that can be configured in Eclipse. You will find Tomcat v7.0 Server under “Apache” folder as shown below.
Click next, and fill in your Tomcat installation directory:
Click Finish, now the configured Apache Tomcat Server will be displayed in the “Servers” view as shown below.
Start Server
Now start and stop it to ensure that it is working properly.
That’s all on how setup eclipse IDE and configuring apache tomcat.