I was writing code in eclipse when a compile error suggested I add exceptions. I clicked on the add exception to existing catch statement and it created a catch block that looked like this:
try{
}catch(SQLException | InvalidKeyException | BadPaddingException
| IllegalBlockSizeException | NoSuchAlgorithmException
| NoSuchPaddingException e){
e.printStackTrace();
}
I have never seen that syntax before but it ran fine through eclipse. When I ran it through my AIX server I got these errors:
forecast_transmission_v2.java:813: <identifier> expected
}catch(SQLException | InvalidKeyException
^
forecast_transmission_v2.java:813: '{' expected
}catch(SQLException | InvalidKeyException
^
forecast_transmission_v2.java:814: illegal start of expression
| BadPaddingException | IllegalBlockSizeException
^
forecast_transmission_v2.java:814: ';' expected
| BadPaddingException | IllegalBlockSizeException
^
forecast_transmission_v2.java:815: not a statement
| NoSuchAlgorithmException | NoSuchPaddingException e){
^
forecast_transmission_v2.java:815: ';' expected
| NoSuchAlgorithmException | NoSuchPaddingException e){
^
forecast_transmission_v2.java:815: not a statement
| NoSuchAlgorithmException | NoSuchPaddingException e){
^
forecast_transmission_v2.java:815: ';' expected
| NoSuchAlgorithmException | NoSuchPaddingException e){
I am assuming that this syntax is something new to Java7 and that is why this is happening. Can anyone verify this or is there another reason for this error?
It is indeed a Java 7 feature.