public class EcmDef { public static void main(String[] args) { try { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); int result = ecm(i, j); System.out.println("i / j is " + result); } catch (EcDef e) { e.printStackTrace(); } catch (NumberFormatException e) { e.printStackTrace(); } catch(ArithmeticException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); } } public static int ecm(int i, int j) throws EcDef { if (i < 0 || j < 0) { throw new EcDef("no smaller zero"); } return i / j; } } public class EcDef extends Exception{ static final long serialVersionUID = -3387516993124229948L; public EcDef() { } public EcDef(String msg) { super(msg); } }