12/11/2016 - 3:32 AM



check is Java is already installed;

/usr/libexec/java_home -V

install Java on OS X;

java -version   # select "More Info" on pop-up dialoge and download latest JDK jdk-8uXXX-macosx-x64.dmg and install
cd `ls -1d /Library/Java/JavaVirtualMachines/jdk1.8.*.jdk | sort -rn -t _ -k 1.42 -k 2 | head -1`
sudo defaults write `pwd`/Contents/Info.plist JavaVM -dict-add 'JVMCapabilities' '<array><string>JNI</string><string>BundledApp</string><string>CommandLine</string></array>'
sudo chmod 0664 Contents/Info.plist
sudo plutil -convert xml1 Contents/Info.plist
sudo mkdir -p Contents/Home/bundle/Libraries
cd Contents/Home/bundle/Libraries
sudo ln -s ../../jre/lib/server/libjvm.dylib libserver.dylib
echo 'export JAVA_HOME="/usr/libexec/java_home"' >> ~/.zshrc
echo 'JDK_HOME=$(/usr/libexec/java_home)' >> ~/.zshrc
echo 'JRE_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre"' >> ~/.zshrc
chmod u+x ~/.zshrc
source ~/.zshrc

remove Java on OS X;

to remove JDK;
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk*.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

install Java on Ubuntu;

sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
cd ~
wget -qO - | sudo apt-key add -
echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update