Java NetBeans sending value and receiving value from Arduino
You are writing a number as a single byte and expect it as a string on the other end.

Replace

val = Serial.parseInt();


with

val = Serial.read();