./opatch: line 839: [: too many arguments Java (1.x) could not be located

After writing article How to Upgrade OPatch to Latest Version, a few reader raised concerns that they got following error when calling opatch binaries.

./opatch: line 839: [: too many arguments
Java (1.7) could not be located. OPatch cannot proceed!
OPatch returns with error code = 1

Even after ensuring that java is installed and all relevant environment variables were also set correctly. The OPatch utility’s md5sum was compared and there was no corruption.

To fix this we can use the “-jdk” argument of opatch to explicitly specify the java home by using following command:

$ORACLE_HOME/OPatch/opatch version -jdk $ORACLE_HOME/jdk

And then subsequent calls to opatch should work if not then you can use this “-jdk $ORACLE_HOME/jdk” clause everytime when you call opatch.

This issue was faced by a few readers, though they confirmed that the env. variables were set appropriately but its very unlikely that this error could occur without any gaps with env. variables and that’s why explicitly specifying the java home does work. Still in case you can’t figure out the gap with env. variable you could always use this workaround.

Feel free to comment below if you faced this error but the issue is not resolved even after using -jdk clause and we’ll work of identifying the root cause together.

5 thoughts on “./opatch: line 839: [: too many arguments Java (1.x) could not be located

  1. This was a bad advise. Yes, this works temporarily, but laten with datapatch apply i got an ORA-06502. The cause was as simple als the solution. You downloaded the wrong version of opatch for your system. in my case i downloaded Version LINUX_X86 instead on LINUX_X86-64
    My Advice: Check, if your current opatch-version matches the oracle server version

    Like

  2. If you are having this problem, you might have downloaded the wrong opatch zip, as I did. I downloaded the “Linux x86” package on my “Linux x86-64” server…

    Like

  3. Exact same issue. Had downloaded the wrong version. I downloaded the “Linux x86” package on my “Linux x86-64” server. optach version command now works without the -jdk. Be careful ;o)

    Like

  4. The workaround did work initially for me, by the time it got to datapatch step, QOPATCH has similar too many parameters error, it turned out downloaded the 32 but opatch instead of 64 but

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.