#!/bin/bash unset JAVA_HOME unset CLASSPATH unset LD_LIBRARY_PATH export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1 export PATH=$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH exec $ORACLE_HOME/OPatch/opatch "$@" Before any patching, run:
$ORACLE_HOME/OPatch/opatch lsinventory -debug Search for “Java detection” or “JAVA_COMMAND”. If you see java -1.6- in the debug output → The Perl variable substitution failed at a low level. $ORACLE_HOME/OPatch/opatch version If version ≥ 13.9 and your Java is 1.6 → Root cause 3.5 . 5. Resolution Strategies 5.1 Quick Fix (Most Common) Unset JAVA_HOME – Often the system JAVA_HOME conflicts with the Oracle home’s embedded Java. opatch cannot proceed"
ls -l $ORACLE_HOME/jdk/bin/java ls -l $ORACLE_HOME/jre/bin/java which java If none exist → . Step 2 – Test Java Executability $ORACLE_HOME/jdk/bin/java -version If it fails with “Permission denied” or “cannot execute” → Root cause 3.4 (SELinux/permissions). Step 3 – Inspect OPatch Perl Files file $ORACLE_HOME/OPatch/opatch.pl perl -c $ORACLE_HOME/OPatch/opatch.pl Look for “syntax OK”. If you see compilation errors or mixed line endings → Root cause 3.2 . Step 4 – Check Environment Variables env | grep -E "JAVA_HOME|CLASSPATH|PATH" If JAVA_HOME points to a nonexistent or wrong Java version, unset it: unset JAVA_HOME and retry. Step 5 – Force OPatch’s Java Detection Verbose Run: usually triggered by environment pollution
$ORACLE_HOME/OPatch/opatch lsinventory -invPtrLoc $ORACLE_HOME/oraInst.loc > /dev/null if [ $? -eq 1 ]; then echo "Java detection failure - abort patching" exit 1 fi The error “java -1.6- could not be located. opatch cannot proceed. opatch returns with error code 1” is not a simple “missing Java 1.6” problem. It is a symptom of broken Java discovery logic within OPatch , usually triggered by environment pollution, corrupted Perl scripts, or permission issues. The “-1.6-” is an artifact of uninitialized variables, not a version requirement. corrupted Perl scripts
set JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_202 Or use opatch.bat with -jre flag:
my $java_cmd = "java -$majorVer.$minorVer-"; if (! -x $java_cmd) die "java -$majorVer.$minorVer- could not be located. opatch cannot proceed";
Look at a sanitized snippet from older opatch.pl or opatch_generic.pl :