Java @ Desk: Eclipse | Java at your desk

Eclipse Maven Change Repository Location

Eclipse Maven Change Repository Location

By default, the maven repository location is "C:\Documents and Settings\USER_NAME\.m2". In order to change the default location for Maven repository, location needs to be updated with the desired location.

To change the default location follow steps :

1) Navigate to folder "C:\Documents and Settings\USER_NAME\.m2"
2) If settings.xml is not available, create the file
3) Add below code in the xml


<settings><localRepository>F:/Projects/Installers/maven</localRepository></settings>


4) Once done, go to eclipse and do a "mvn install"

The above command will download all the dependencies at the above location.

To verify, change the pom.xml and verify as shown in below image

Eclipse Luna - Add Web Development Tools and Tomcat Server Plugin

Eclipse Luna - Add Web Development Tools and Tomcat Server Plugin

Eclipse Luna installation does not have plugins for Web Development as well as to Add new servers within Eclipse. To do so, you need to install two plugins -
1) Web Development Tools - To enable dynamic web application view perspective
2) Server Tools - To add new server in Eclipse

Steps to install Web Development Tools :
1) In Eclipse Luna, go to Help, select "Install New Software"
2) Add new Site "Luna – http://download.eclipse.org/releases/luna"
3) Select "Web, XML, and Java EE Development"
4) Select Eclipse Java EE Developer Tools, Eclipse Java Web Developer Tools, Eclipse Web Developer Tools.

Steps to install Server Tools :
1) In Eclipse Luna, go to Help, select "Install New Software"
2) Add new Site "Luna – http://download.eclipse.org/releases/luna"
3) Search JST and select JST Server Adapters and JST Server Adapters Extensions
4) Install

Solve java.lang.OutOfMemoryError: Java heap space Eclipse

Solve java.lang.OutOfMemoryError: Java heap space Eclipse

Running a main file which has high memory consumption may crash due to less memory availability.

To increase the memory allocation at runtime, the configuration can be done in the eclipse via the VM Arguments as shown below

Click on Run -> Run Configuration and make settings as shown below :

Configure log4j in eclipse without using log4j.properties file

Log4J Implementation in Eclipse without using log4j.properties file:
There are three implementations for configuration of log4j in eclipse.

Required files for the implementation are:
1) log4j.jar
Create a new Java project and name it as LoggerImpl
Create package com.logger and create Log4JPropertyFile.java

Configure log4j in eclipse using PropertyConfigurator class

Log4J Implementation in Eclipse using PropertyConfigurator:
There are three implementations for configuration of log4j in eclipse.

Required files for the implementation are:
1) log4j.jar
2) log4j.properties
3) mylog4j.properties

How to configure log4j in eclipse

Log4J Implementation in Eclipse:
There are three implementations for configuration of log4j in eclipse.

Required files for the implementation are:
1) log4j.jar
2) log4j.properties
3) mylog4j.properties

Create a new Java project and name it as LoggerImpl

How to attach a source in java eclipse


1) Click on any java class. For instance write a code

ArrayList arrayList = new ArrayList();
Click on ArrayList and navigate to class. Now click on attach source button and select the src folder from your JDK folder. For e.g. C:\Program Files\Java\jdk1.7.0

If src folder is not available then download it and place in that folder