Tuesday, August 18, 2009

Avoid Permgen space exception in Jboss and Eclipse

Hi All,
Add the following line of code in your eclipse under Jboss-arguments section.
Steps
1. Double click on the JBoss server which you already added to your eclipse.
2. Click on open launch configuration link.
3. After clicking this link one new window will open with edit launch
configuration properties.
4. In this window place the following code in your VM arguments Area section.
5.Click on save this(CTRL+S).

-Dprogram.name=run.bat -Djava.endorsed.dirs="C:/jboss-Location/jboss-eap-4.3/jboss-as/bin/../lib/endorsed" -Xms512m -Xmx512m -XX:MaxPermSize=128m


Jboss-Location means where is your jboss is placed.
Ex:
My Jobss is there in C:/siva then replace this with Jboss_location.

There is another way to increase permgen space size.
1. open run.bat in either edit plus/wordpad/notepad
2. fist see the following code is commented or not ,find this is there or not
if it is commented uncommented, it is not there then paste it in run.bat file
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m


I hope this will help you to avoid permgen space exception.

Saturday, March 14, 2009

Common Utility methods

1.Convert from Date object to String with given format
/**
* Formats the date object in given format.
* @param aDate the date object
* @param aNewformat the new format
* @return string in new format.
*/
public static String getFormattedDate(Date aDate, String aNewformat)
{
if (aDate != null)
{
SimpleDateFormat dateFormat = new SimpleDateFormat(aNewformat);
String formattedDate = dateFormat.format((aDate));
return formattedDate;
}
return "";
}
2.Convert Calendar To String with given format
/**
* Formats the date object in given format.
* @param aCalendar the date object
* @param aNewformat the new format
* @return string in new format.
*/
public static String getFormattedDate(Calendar aCalendar, String aNewformat) {
//For Ex: aNewformat =dd/mm/yyyy
if (aCalendar != null)
{
SimpleDateFormat dateFormat = new SimpleDateFormat(aNewformat);
String formattedDate = dateFormat.format((aCalendar.getTime()));
return formattedDate;
}
return "";
}
3.Convert Calendar to Date
/**
* Checks calendar object for null and returns date object.
* @param aCalendar the calendar object to check.
* @return Date object or null
*/
public static Date getTime(Calendar aCalendar)
{
if (aCalendar != null)
{
return aCalendar.getTime();
}
return null;
}
You Can Find More on SimpleDateFormat click here

AddToAny

Contact Form

Name

Email *

Message *