Installing Oracle Java on Ubuntu x64 (Using your Windows Share)

Download the Oracle JDK GZ that you wish to install on your target Ubuntu x64 Clients.

Save the GZ on the Windows share being used for deploying applications using Management Utilities

In our example we are using a share on our server\apps\linuxapps\ it uses the same username and password as used in our windows Authentication to access the share - this will be used in the script

**Please Note - you must run the commands silent with no output or user prompts

Script - Install JDK x64 (Windows Share)

Create the following script using a text editor on Linux or using or with Notepad++ (with EOL Conversion set to Unix) and save it to the shared apps folder on the windows server

In our example we are using the following to access the share:

username = administrator

password = SyAM123$

path = \\\apps\linuxapps\

In our example we are using the following for the ubuntu user password to run as sudo:

Ubuntu user password = 12345678


echo 12345678 | sudo -S apt-get purge openjdk-\*

echo 12345678 | sudo -S mkdir -p /usr/local/java

echo 12345678 | sudo -S smbget -n -q -u administrator -p SyAM123 $ smb://

echo 12345678 | sudo -S cp -r jdk-8u77-linux-x64.gz /usr/local/java

cd /usr/local/java

echo 12345678 | sudo -S chmod a+x jdk-8u77-linux-x64.gz

echo 12345678 | sudo -S tar zxvf jdk-8u77-linux-x64.gz > /dev/null

echo 12345678 | sudo -S update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_77/bin/java" 1

echo 12345678 | sudo -S update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_77/bin/javaws" 1

echo 12345678 | sudo -S update-alternatives --set java /usr/local/java/jdk1.8.0_77/bin/java

echo 12345678 | sudo -S update-alternatives --set javaws /usr/local/java/jdk1.8.0_77/bin/javaws

cd $home

echo 12345678 | sudo -S rm -f jdk-8u77-linux-x64.gz

**Please Note your script must be saved as .sh

**Please Note - This will only work on Ubuntu 64bit

Now create a Third Party Template to run the script

Give the template a name, select Linux, choose the Authentication Template that contains the username and password for both Windows App share file access the root level user on the Linux target system

Click find files to select your script, press Add and the check the Copy check box.