AWTError in Java

Class AWTError in Java

An AWTError is thrown from an application when a serious Abstract Toolkit Error has occurred during execution. It is a runtime exception.

If an application throws an AWTException, the java virtual machine stops its execution. A coder optionally chooses to throw this error if a nonrecoverable and serious run time error occurs.

How to throw AWTError from the command line?

The AWTError is generated as java tries to invoke somekit toolkit and it is not present in the CLASSPATH.

 java - Dawt.toolkit=somekit ThrowAWTError

How the getDefaultToolKit() throws AWTError?

The following code can explain how the getDefaultToolKit.


import java.awt.Toolkit;
public class ThrowAWTError{
public static void main(String args[])
{
Toolkit.getDefaultToolkit();
//error occurs here
}

The class structure of the AWTError is given as:

public class java.awt.AWTError extends java.lang.Error{
//constructor
public AWTError(String message);
//constructs an AWTError with the specified detailed message.
} 

Share and Enjoy !

Leave a Reply

Your email address will not be published. Required fields are marked *