java8.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. RETCODE=$(fw_exists java8.installed)
  3. [ ! "$RETCODE" == 0 ] || { \
  4. # Load environment variables
  5. source $IROOT/java8.installed
  6. return 0; }
  7. # TODO: Someday get away from apt-get
  8. sudo add-apt-repository -y ppa:webupd8team/java
  9. sudo apt-get update
  10. echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
  11. sudo apt-get install -y oracle-java8-installer
  12. # set Java 7 (OpenJDK) as the default, as before.
  13. J7_HOME=/usr/lib/jvm/java-7-oracle
  14. sudo update-alternatives --set java $J7_HOME/jre/bin/java
  15. sudo update-alternatives --set javac $J7_HOME/bin/javac
  16. # try to make sure all JDK binaries default to OpenJDK 7, not Java 8
  17. update-alternatives --get-selections | grep java-8 | sed -e "s|java-8-oracle|$J7_HOME|" | while read line
  18. do
  19. l=(${line// / })
  20. n=${l[0]}
  21. p=${l[2]}
  22. if [ -e "$p" ]; then
  23. sudo update-alternatives --set $n "$p"
  24. fi
  25. done
  26. # Setup environment variables
  27. JAVA_HOME=/usr/lib/jvm/java-8-oracle
  28. echo "export JAVA_HOME=${JAVA_HOME}" > $IROOT/java8.installed
  29. echo -e "export PATH=\$JAVA_HOME/bin:\$PATH" >> $IROOT/java8.installed
  30. source $IROOT/java8.installed