Installing Oracle MetaLink Patches Without Perl
Tuesday, 5. December 2006, 15:55:14
MetaLink is a good place to solve your major problems, that is of course if your work has a MetaLink account.
If the solution to your problem is an Oracle patch, the instructions will tell you that you need perl to be able to install it. This comes with OracleAS, but not with JDeveloper or standalone OC4J.
After being told that a patch would solve a problem I had in JDeveloper embedded OC4J and the standalone OC4J, I queried MetaLink on how to install them without perl. They came back with a load of command prompt lines that were specific to the patch to install them. I decided to make a generic batch script to install any patch to any OC4J installation.
orapatch.bat
If you copy and paste this into a new text file called orapatch.bat and then save it. You can run it from the command prompt with this command:
Where <patch path> is the absolute or relative path to the extracted patch folder, <oc4j path> is the absolute or relative path to the OC4J installation and <backup dir> is the name of the directory you want the backed up files to go to.
Example:
When you run the batch file you will see that it adds some files to two jars in the OC4J installation.
All you need to do then is test that it works as it should. If for some reason it doesn't, the output at the end of the script will tell you where the original files are.
Edited 6th December 2006: Fixed a couple of bugs in the script
If the solution to your problem is an Oracle patch, the instructions will tell you that you need perl to be able to install it. This comes with OracleAS, but not with JDeveloper or standalone OC4J.
After being told that a patch would solve a problem I had in JDeveloper embedded OC4J and the standalone OC4J, I queried MetaLink on how to install them without perl. They came back with a load of command prompt lines that were specific to the patch to install them. I decided to make a generic batch script to install any patch to any OC4J installation.
orapatch.bat
@echo off :: Installer for Oracle Patches :: Parameters: :: <patch path> The absolute or relative path to the patch folder :: <oc4j path> The absolute or relative path to an oc4j instance :: <backup dir> The directory name to store the backups :: e.g. orapatch C:\1234567 "C:\Program Files\JDeveloper" JDeveloper :: or D:\7654321 D:\oc4j "Standalone OC4J" :initial if "%~3"=="" goto useerror set PATCH_DIR=%~f1 set OC4J_DIR=%~f2 set BACKUP_DIR=%~3 if not exist "%PATCH_DIR%" goto patherror2 if not exist "%PATCH_DIR%\files\j2ee\home\" goto patherror2 if not exist "%OC4J_DIR%" goto patherror if not exist "%OC4J_DIR%\j2ee\home\lib" goto patherror if not exist "%PATCH_DIR%\backup" md "%PATCH_DIR%\backup" if not exist "%PATCH_DIR%\backup\%BACKUP_DIR%" md "%PATCH_DIR%\backup\%BACKUP_DIR%" if not exist "%PATCH_DIR%\temp" md "%PATCH_DIR%\temp" set TEMP_DIR=%PATCH_DIR%\temp if not exist "%PATCH_DIR%\files\j2ee\home\lib\oc4j-internal.jar" goto client echo Patching oc4j-internal.jar copy "%OC4J_DIR%\j2ee\home\lib\oc4j-internal.jar" "%TEMP_DIR%\oc4j-internal.jar" > NUL jar -ufv0 "%TEMP_DIR%\oc4j-internal.jar" -C "%PATCH_DIR%\files\j2ee\home\lib\oc4j-internal.jar" . copy "%OC4J_DIR%\j2ee\home\lib\oc4j-internal.jar" "%PATCH_DIR%\backup\%BACKUP_DIR%\oc4j-internal.jar.original" > NUL copy "%TEMP_DIR%\oc4j-internal.jar" "%OC4J_DIR%\j2ee\home\lib" > NUL :client if not exist "%PATCH_DIR%\files\j2ee\home\oc4jclient.jar" goto finish echo. echo Patching oc4jclient.jar copy "%OC4J_DIR%\j2ee\home\oc4jclient.jar" "%TEMP_DIR%\oc4jclient.jar" > NUL jar -ufv0 "%TEMP_DIR%\oc4jclient.jar" -C "%PATCH_DIR%\files\j2ee\home\oc4jclient.jar" . copy "%OC4J_DIR%\j2ee\home\oc4jclient.jar" "%PATCH_DIR%\backup\%BACKUP_DIR%\oc4jclient.jar.original" > NUL copy "%TEMP_DIR%\oc4jclient.jar" "%OC4J_DIR%\j2ee\home" > NUL goto finish :finish echo. echo OC4J installation at %OC4J_DIR% patched. echo Backed up files stored in %PATCH_DIR%\backup\%BACKUP_DIR%. rd /S /Q "%TEMP_DIR%" set PATCH_DIR= set OC4J_DIR= set BACKUP_DIR= set TEMP_DIR= goto done :useerror echo Usage: orapatch ^<patch path^> ^<oc4j path^> ^<backup dir^> echo. echo e.g. orapatch C:\Patches\7654321 C:\JDeveloper JDeveloper goto done :patherror echo Specified path (%OC4J_DIR%) is not an OC4J installation. goto done :patherror2 echo Specified path (%PATCH_DIR%) is not an Oracle patch. goto done :done
If you copy and paste this into a new text file called orapatch.bat and then save it. You can run it from the command prompt with this command:
orapatch <patch path> <oc4j path> <backup dir>
Where <patch path> is the absolute or relative path to the extracted patch folder, <oc4j path> is the absolute or relative path to the OC4J installation and <backup dir> is the name of the directory you want the backed up files to go to.
Example:
orapatch "C:\Oracle Patches\1234567" "C:\Program Files\JDeveloper" "JDeveloper Backup"
When you run the batch file you will see that it adds some files to two jars in the OC4J installation.
All you need to do then is test that it works as it should. If for some reason it doesn't, the output at the end of the script will tell you where the original files are.
Edited 6th December 2006: Fixed a couple of bugs in the script