It's acutely not Java, it's JavaScript - similar name, but completely different language.
There is one potential problem with this script: If Field_2 is set to 0, then your calculation will result in "Not a Number" (or NaN), so we need to prevent that. If that's not a problem, then you could just use the "Simple Field Notation" format, and get away without using JavaScript:
1 - (Field_1 / Field_2)
If you need to prevent the Infinity or NaN, then you have to go with JavaScript. The following script will only show a result if both Field_1 and Field_2 have valid data:
var f1 = this.getField("Field_1").valueAsString;
var f2 = this.getField("Field_2").valueAsString;
if (f1 != "" && f2 != "" && f2 != 0) {
event.value = 1 - (f1 / f2);
}
else {
event.value = "";
}
Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com