Hi
The only 2 reasons I can think of
1. The Gateway host is not correct. Please check that the IP entered is correct and same as the host mentioned in the Gateway settings
2. The Program ID is same in ABAP and JAVA. Though they seem correct sometimes spaces may cause such error,
Please verify one of the above is not the reason.
Regards
Partha