If they are all the same value, you can collapse it like this:
unique values of (it as trimmed string) of following texts of firsts "JAVA_HOME=" of lines whose ( it contains "JAVA_HOME=" ) of files "/opt/anthill3/agent/bin/ah3agent"
Also, is there a character that denotes a comment so that those lines can be excluded?
This is one way you can get the first value only:
tuple string items 0 of concatenations ", " of (it as trimmed string) of following texts of firsts "JAVA_HOME=" of lines whose ( it contains "JAVA_HOME=" ) of files "/opt/anthill3/agent/bin/ah3agent"
This method depends on there not being a comma followed by a space in the actual values.