$ ./mactechbuds.sh
Starting MacTechBuds...
Blog engine loaded ✓
AI tools ready ✓
Bash scripts active ✓
Timer system ready ✓
Theme engine active ✓
Dev tools online ✓
mactechbuds.com >
Back to Tech Thoughts

Script for Java Management on macOS

Overview

Managing Java versions on macOS endpoints can be challenging. The following scripts assist in removing older versions (specifically Oracle Java 8) and identifying installed versions for inventory purposes.

Script: Java_8_removal.sh

This script removes Oracle Java 8 (JDK 1.8) from the system and then updates the Jamf Pro inventory.

#!/bin/sh

#  Java_8_removal.sh
#  
#
#  Created by Shri Sivakumaran C on 04/09/23.
#  
LoggedUser=$(stat -f "%Su" /dev/console)
echo $LoggedUser

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane


sudo rm -rf /User/$LoggedUser/Library/Application\ Support/Oracle/Java

rm -fr /Library/Java/JavaVirtualMachines/jdk1.8*
  
  ##update inventory to Jamf Pro
  jamf recon

exit 0

Note: This script uses sudo to remove system-level files and directories.