PROGRAM:
~~~~~~~~~
import java.io.*;
class ExceptionHandle{
public static void main(String[] args) throws Exception{
try{
int a,b;
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
a = Integer.parseInt(in.readLine());
b = Integer.parseInt(in.readLine());
}
catch(NumberFormatException ex){
System.out.println(ex.getMessage()
+ " is not a numeric value.");
System.exit(0);
}
}
}
NOTE:ex.getMessage() prints the information about the error occurring causes.
EXECUTED USING NETBEANS IDE.
DISPLAYED EXCEPTION:
~~~~~~~~~~~~~~~~~~~~
java.lang.NoClassDefFoundError: exceptionhandle/ExceptionHandle (wrong name: ExceptionHandle/ExceptionHandle)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: exceptionhandle.ExceptionHandle. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
No comments:
Post a Comment