Code example for InvocationTargetException

Methods: getMessagegetCause

			return method.invoke(obj, newValue);
		} catch (IllegalAccessException e) {
			throw new NoSuchMethodException(methodName + " is not accessible");
		} catch (InvocationTargetException e) {
			// The method is not supposed to throw exceptions 
			InternalError error = new InternalError(e.getMessage());
			error.initCause((e.getCause() != null) ? e.getCause() : e);
			throw error;
	 * Invokes the specified setter method if it exists. 
	 * @param obj		  The object on which to invoke the method. 
	 * @param methodName The name of the method. 
	public static void invokeIfExists(Object obj, String methodName) {
		try { 
			invoke(obj, methodName);
Stop searching for code, let great code find you!  Add Codota to your java IDE