Application use java. When run script, it returns

./browser.sh ./browser.sh: 7: ./browser.sh: java: not found

I check java version:

java -v
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * openjdk-7-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

Which package should I install?

  • 1
    I wonder why it does not mention openjdk-8-jre (or openjdk-8-jre-headless), that would have been my choice. – Byte Commander Aug 5 '16 at 11:09
  • 2
    @ByteCommander OpenJDK 8's final release was on 3/18/2014, probably too late to be included in the main Ubuntu 14.04 repositories. It does seem as though it should be available through backports or something, though. – Nick Weinberg Aug 5 '16 at 12:12

You could install the default-jre, that is openjdk-7.

This should be the more stable of all jre.

| improve this answer | |
  • The applications written in Java require have installed both the JRE and JDK? – minto Aug 6 '16 at 10:17
  • JRE means Java Runtime Environment, that is all needed to execute a Java application. JDK means Java Development Kit, is all needed to make Java applications. So if you only want to execute Java applications, JRE is ok. – melchor629 Aug 6 '16 at 11:05
  • I installed default-jre (I assumed its JRE only), but when I checked version it show it installed also JDK -- why? java -showversion java version "1.7.0_101" OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode) – minto Aug 6 '16 at 20:44
  • Its only its name of the project: 'openjdk'. This not mean that have been installed the JDK :) – melchor629 Aug 6 '16 at 20:53

Very easy :

sudo add-apt-repository ppa:webupd8team/java

After that, update package lists via:

sudo apt-get update

To install Oracle Java 8, run:

sudo apt-get install oracle-java8-installer

Change the number 8 to 6 (or 7) in the code to install Java 6 (or 7).

To set the default Java, run:

sudo apt-get install oracle-java8-set-default

Also change number 8 to the Java version you want.

Finally check whether everyting is OK:

java -version
| improve this answer | |

The best way to install JDK on ubuntu is manually by downloading from oracle. You can refer following documentation for easy installation.

6 Easy way to install Java JDK on Ubuntu

| improve this answer | |
  • 1
    Welcome to Ask Ubuntu! Please edit your question to add the relevant parts of the web site you linked to directly in your answer. Thanks! – grooveplex Aug 5 '16 at 14:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.