Pipe doesn't work after reg query?-Collection of common programming errors

Error messages are sent to Standard Error and to Standard Output hence you need to redirect Standard Error to Standard Output before running find on the output.

reg query "HKLM\Software\JavaSoft\Java Runtime Environment" 2>&1 | find "ERROR" > nul

Another thing is that reg query itself returns 0 or 1 on success or failure

Return Code: (Except for REG COMPARE)
  0 - Successful
  1 - Failed

So you may not have to use find at all.

reg query "HKLM\Software\JavaSoft\Java Runtime Environment"  > nul 2> nul

if %errorlevel% == 0  goto success
echo "Not found"
goto end
:success
echo "Found"
:end

I am just printing Found/Not found – but you can take whatever action you want.