java.lang.long cannot be cast to java.lang.integer

Java
Long.valueOf(x).intValue()
Source

Also in Java: