Posts

Showing posts with the label Exceptions

about user defined exception in Java

User defined exceptions may be implemented by defining a new exception class by extending the Exception class. public class MyException extends Exception { /* class definition of constructors goes here */ public MyException() { super(); } public MyException (String errorMessage) { super (errorMessage); } } Throw and/or throws statement is used to signal the occurrence of an exception. Throw an exception: throw new MyException(“I threw my own exception.”) To declare an exception: public myMethod() throws MyException {…}

about Exceptions in Java

Exceptions in Java -     An Exception is phenomenal condition, which can comes your program when program is executed. And this condition interrupt with program's normal flow.     When any program face the exceptional condition, an exception object is made by JVM and program will be terminate.             For prevent the termination of program, There is need to handle this situation.     There are three type of exceptional event occurs.     1)Error 2)Checked Exceptions 3)Unchecked Exceptions Errors - Error can be occurs for network failure, Hardware failure or any other reason besides your programs. So you can not handle this through program code. Checked Exceptions -     Java compiler checks your code at compile time. If any exception occurs in this time error handler read this at compile time. This is called checked exceptions.   ...

Difference NoClassDefFoundException and ClassNotFoundException

NoClassDefFoundException occurs when class is loaded as statically and ClassNotFoundException occurs when class is loaded as dynamically. Static class loading:- Car c = new TestClass(); Dynamically class loading:- Class.forName(“ TestClass ”); According to arun:- Consider, you have two custom classloaders - CL1 and CL2. A class loaded by CL1 when tried to be accessed by CL2 will also throw a ClassNotFoundException. And consider you have Class1 loaded by both CL1 and CL2, they both are not compatible even through they are the same. There we give some job to ClassCastException. Thanks Arun www.arunma.com

java.lang.UnsupportedClassVersionError major.minor version 49.0

java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main (Unsupported major.minor version 49.0) Solution:-      If you are using 1.5 version of java so please update 1.6 version of java For Eclipse 3.1 setting. Right click on your project --> Popup window will be opend --> select java build path in left side navigation bar --> Click JRE System LIbrary --> edit button --> Choose Alternate JRE: and click on Installed JREs... button. --> new Popup will be opened --> Click JRE home directory: browse... button --> and select java 1.6.0 directory. --> Write JRE name --> Click Ok button. --> Select your new jre and click ok button. --> then Select Alternate JRE from drop down list. --> Click on Finish.

BeanUtils.populate IllegalArgumentException: array element type mismatch

type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: BeanUtils.populate org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:627) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) root cause java.lang.IllegalArgumentException: array element type mismatch java.lang.reflect.Array.set(Native Method) org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:464) org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:986) org.apach...

what is StringIndexOutOfBoundsException in java code example

StringIndexOutOfBoundsException :- StringIndexOutOfBoundsException is thrown by the String class, if index in the string is passing greater then the string size or negative value of index in string. Example:- public class Test {         public static void main(String[] args) {                              

Recent Post

Recent Posts Widget