1

I followed the following commands to install android studio:

sudo apt-add-repository ppa:paolorotolo/android-studio
sudo apt-get update
sudo apt-get install android-studio

but gave the following error:

Lendo listas de pacotes... Pronto
...
A requisição HTTP foi enviada, aguardando resposta... 404 Not Found
2017-10-02 16:10:02 ERRO 404: Not Found.

download failed
Oracle JDK 7 is NOT installed.
dpkg: erro ao processar o pacote oracle-java7-installer (--configure):
 sub-processo script post-installation instalado retornou estado de saída de erro 1
dpkg: problemas com dependências impedem a configuração de oracle-jdk7-installer:
 oracle-jdk7-installer depende de oracle-java7-installer; porém:
  Pacote oracle-java7-installer não está configurado ainda.

dpkg: erro ao processar o pacote oracle-jdk7-installer (--configure):
 problemas de dependência - deixando desconfigurado
Nenhum relatório apport escrito pois a mensagem de erro indica que é um erro de seguimento de um erro anterior.
                               Erros foram encontrados durante o processamento de:
 oracle-java7-installer
 oracle-jdk7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried reinstalling java 7, it installs normally and the error persists

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

and can not install java 7. I can not seem to get the dowload, or the problem with sevices, the same java installation error. Can someone tell me how to solve this?

UPDATE

/usr/lib/jvm/java-6-oracle/jre/bin/java
/usr/lib/jvm/java-8-openjdk-i386/jre/bin/java
/usr/lib/jvm/java-8-oracle/jre/bin/java
/usr/lib/jvm/java-9-oracle/bin/java
Marcius Leandro
  • 775
  • 1
  • 11
  • 34
  • Let's see the output from `update-alternatives --list java` –  Oct 02 '17 at 19:52
  • Are you sure that PPA is for the JDK? –  Oct 02 '17 at 19:53
  • 1
    I hate to say it, but for something like Android Studio, I'd use the standalone installer instead of a package. It'll work with JDK 8. –  Oct 02 '17 at 20:09
  • That all being said, this looks like a problem better suited for Ask Ubuntu, as it has to do with installing dependent packages on a specific OS. –  Oct 02 '17 at 20:10
  • As @jdv suggested, Why don't you try with JDK standalone installer. There are thousands of tutorials to get it up and running. I'm also using Ubuntu 16.04 and I installed JDK using standalone installer, it works fine. – Shashanth Oct 03 '17 at 09:54
  • Heck, you can even use "SDKMAN" if that doesn't work. –  Oct 03 '17 at 14:51

2 Answers2

0

Do the following:

1.

sudo add-apt-repository ppa:webupd8team/java

2.

sudo apt-get update

3.

sudo apt-get install oracle-java8-installer

4.

sudo update-alternatives --config java

There are 5 choices for the alternative java (providing /usr/bin/java) Press to keep the current choice[*], or type selection number:

5. set $JAVA_HOME in the /etc/environment/ file with something like JAVA_HOME="/usr/lib/jvm/java-8-oracle" Dont forget to use the correct java path while defining JAVA_HOME.

Sparkplug
  • 485
  • 7
  • 21
  • @MarciusLeandro: Can you please let me know the output of `echo $JAVA_home` and `which java`? – Sparkplug Oct 03 '17 at 09:18
  • Please note that you do not need to use the Oracle VM! And if you want to develop you probably want OpenJDK (with a stress on the "JDK" part. Tweaking PPAs and JAVA_HOME when all the packages we need are available, and when /etc/alternatives exists is a bit of a hack. –  Oct 03 '17 at 14:53
0

This is an X-Y problem! You want to run Android Studio, and the latest one (at the time of writing) works fine with (and may even require) Java 8. So:

  1. Download and install OpenJDK 8 somehow. Yes, you technically don't need the JDK, but it is a good habit to get into. If you ever want to run Eclipse, it used to require the JDK version of the VM to run (though Eclipse is different from AS in this regard.) Just install the JDK using one of the usual methods:
    • You can install OpenJDK 8 from the usual packages as described here. In most cases this is as simple as apt install default-jdk but check your apt-cache results.
    • Use a shell tool like SDKMAN to install and manage a stable of JDKs and Java tools. If you need to switch tooling versions a lot, and don't want to be in the business of tweaking shell environments to manage build- and run-time issues, this is the way to go.
  2. Download and install the latest Android Studio from Google. I would recommend against using the Ubuntu package for things like Android Studio or Eclipse. The versions always lag, you run into dependency issues, and modern IDEs update themselves anyway.

I would specifically recommend against installing the "Oracle" package unless you really need it for some specific reason. And even then you probably don't. OpenJDK is the reference implementation for Linux and Windows, and is the most correct JDK (in terms of what is used when testing these IDEs) for Android or Java development on common platforms.

I also specifically recommend staying away from hacking JAVA_HOME all the time, because then you are in the business of maintaining JAVA_HOME all the time. Ubuntu has a very good "alternatives" system that makes this easily manageable. Or you can use SDKMAN which makes selecting default and current VM selection into a series of shell commands. As a developer, try to reduce the amount of ceremony you have to do just to get your tools to work and keep working over time.

I develop on Debian and Ubuntu using Java 6 through 8, running my tools in later versions and compiling with specific versions of the JDK. I have different versions of tooling like Ant and Gradle for different projects. The only thing that I control with grungy shell script sourcing is a cross-compiler for JNI development. Everything else is done with alternatives and SDKMAN. I never tweak a Java option beyond running update-alternatives and tweaking Ant or Gradle properties.