Hi Jose,
> [...] JAVA updates automatically.
First note: There were similar discussions on the forum related to the automatic updates of web browsers and my personal opinion is that with the enabled auto updates you are getting uncontrollable test environment and this is far not always the best approach.
Indeed, if your company explicitly declares that it supports the latest and only the latest version of, say, Java and accepts responsibility for any reported problems that were caused by the just released Java version (even if new Java was released in the midnight in the middle of the weekend and the issue report arrived 5 minutes later after this), then you have no choice but continuously test on the latest Java version available (what about betas?).
Otherwise, even if you try your best to support the latest version as soon as possible, you must keep your test environment stable and controllable. Disable automatic updates. When the new version is released, create a new documented test environment, check if the environment itself works, check if your tested application can at least start on this new environment, check if your tests still work on the new environment, analyze results and only after that you may dispose of your previous test environment if needed.
With the approach above, in the worst case you still will be able to execute your tests for the new builds of your tested application on the previous test environment and provide the results. But in case of uncontrollable test environment you are at risk of been completely blocked (like you are now) and not been able to provide results for both new and previous test environments.
As for your actual question, it looks like that the case is not updated Java, but updated version of PDFBox library that is used in your code.
As the only thing that you need is to extract text from pdf file, I would recommend to rollback pdfbox library from v.2.x to 1.x.
Otherwise, you may check this thread (https://community.smartbear.com/t5/Desktop-Testing/Compare-pdf-files/m-p/122418#M6672) and try to adjust your test code.