First, let’s get the files we need. Download the contents from here and save to your SCCM Source file directory. Browse to Oracle’s site and download the latest “Windows offline” version. Now launch the installation, but do not click “Install”.
Navigate to %APPDATA%\..\LocalLow\oracle\java
Select the folder of the current JRE version that was downloaded.
Copy and paste the .msi file to your SCCM Source file directory.
In the SCCM console, create a package and name it "Remove Java" or similar. Point the source to the folder containing the downloaded files. Use Remove_old_Java.bat for the command line.
In the Java\disable update folder that was downloaded, edit the javaupdateremove.bat file. Change the path on both lines to reflect where the content is located in your environment then save: regedit.exe /s \\sourceserver\path\Java\disable update\javaupdate.reg and regedit.exe /s \\sourceserver\path\Java\disable update\javaupdate32.reg.
Create a new package and name it "Remove Java Update" or similar. Point the source to the folder containing the downloaded file folder "disable update". Use the command line javaupdateremove.bat.
Create an application to install Java from the .msi extracted earlier.
Create a custom task sequence that:Installs the package to remove all Java
Install the Java application(s)
Install the package to remove Java update.
It is recommended to deploy it as "Available" for end users to install via the software center.