bash: “no such file or directory” for executable in PATH

In my process of installing java (as part of weblogic) with ansible I get this issue. I have seen that before from time to time, but cannot recall the solution.

I have a new linux user “weblogic” in group “weblogic” on a ubuntu24, HOME=/opt/oracle

I ssh to that remote machine as my own user, then I do sudo su weblogic. I export JAVA_HOME and PATH, either via .bashrc or manually

declare -x PATH="/opt/oracle/jdk1.8.0_431/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
declare -x JAVA_HOME="/opt/oracle/jdk1.8.0_431"

But when I do either/or

java
bash: /opt/oracle/jdk1.8.0_431/bin/java: No such file or directory

/opt/oracle/jdk1.8.0_431/bin/java
bash: /opt/oracle/jdk1.8.0_431/bin/java: No such file or directory

Permissions are like that, all the way down from /opt

drwxr-xr-x  4 weblogic weblogic  4096 Dez  9 15:27 oracle/

Originally I assumed it is an issue with ansible i am not aware of and asked here https://stackoverflow.com/questions/79265126/using-the-lookup-ansible-builitin-env-on-the-environment-variable-path-does-not