Cannot start androidstudio only in console

Hi, my problem is the following, I downloaded Android Studio , and if I go to

/ path / android studio / bin

and I execute studio.sh

I get the following error:

 No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation. 

Now, if I export JAVA_HOME

  export JAVA_HOME=/usr/java/jdk1.7.0_25/ 

and execute studio.sh Android Studio, but now I create Symbolic Link to studio.sh

 ln -s /path/android-studio/bin/studio.sh /usr/bin/androidstudio 

and if I run androidstudio in the console, it works, but now I want to create a Gnome launcher

So, I did this:

 vi /usr/share/AndroidStudio.desktop 

and I paste the following code into the file:

 [Desktop Entry] Name=Android Studio GenericName=IDE para Android X-GNOME-FullName=IDE para Android - Android Studio Comment=Desarrolla aplicaciones para Android Exec= /usr/bin/androidstudio Terminal=false StartupNotify=true Type=Application Icon=/opt/android-studio/bin/idea.png Categories=Development; Name[es_ES]=Android Studio 

but at the moment I am running AndroidStudio launcher , it gives me the following error:

  No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation. 

I think to do again:

  export JAVA_HOME=/usr/java/jdk1.7.0_25/ 

Will fix the problem, but no, launcher still does not work: C Thanks in advance!

EDIT

All I did was su as a user.

+2
source share
3 answers

Te contestaré en español porque tu inglés es bastante anemico mano (para los demás, conozco a éste morro) ...

¿Que Linux distribution estas usando? por ejemplo para Fedora , y posteriormente modificar las alternativas, eso depende de tus necesidades de contar con diferentes opciones de JDK (Oracle, OpenJDK, etc. y sus correspond to the version).

En Ubuntu puedes revisar Ubuntu manpage para mayor información de update-alternatives .

Adicionalmente, tienes que agregar a tu PATH la referencia a la carpeta bin/ de tu JDK definida en el export JAVA_HOME=/donde/tengas/tu/jdk , así como a tu CLASSPATH la referencia a tu carpeta lib/ es decir:

 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=$JAVA_HOME/lib 

Nota: Otra cosa que tienes que observar es que en los export es una buena práctica no colocar el último slash (observer los dos export que acabo de agregar, si tuvieran ese último slash en el primero se vería algo así en tu PATH : .../donde/tengas/tu/jdk//bin... not cool bro! ¬¬)

Te recomendaría que adicionalmente a modificar las alternativas (en el caso de ser necesario en tu distro), utilities un enlace simbólico para cualquier JDK que no instales mediante el gestor de paquetes y así tener mayor flexibilidad, por ejemplo:

 lrwxrwxrwx 1 root root 10 jul 16 19:01 java -> oracle-jdk-7 drwxr-xr-x 8 root root 4096 nov 14 2012 jdk1.6.0_25 drwxr-xr-x 8 root root 4096 nov 14 2012 jdk1.6.0_37 drwxr-xr-x 8 root root 4096 feb 15 15:21 jdk1.7.0_15 drwxr-xr-x 8 root root 4096 jun 5 23:07 jdk1.7.0_25 lrwxrwxrwx 1 root root 11 jul 16 19:00 oracle-jdk-6 -> jdk1.6.0_37 lrwxrwxrwx 1 root root 11 jul 16 19:00 oracle-jdk-7 -> jdk1.7.0_25 

y al verificar la versión del JDK se observa:

 [ root@rojas opt]# java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) 

en el caso de necesitar modificar la alternativa, harías referencia a la ruta /ruta/completa/enlace/simbolico/java y con solo cambiar dicho enlace cambiarías de JDK.

Si esto no te parece muy buena opción, pues tendrías que agregar todas esas versiones a las alternativas (y cada que descargues una nueva, repetir el proceso) ... es cosa de que veas que te resulta más cómodo.

Una vez que terminaste de hacer esos exports, ¿ejecutaste el comando source ?

 source /path/a/archivo/donde/tienes/todos/esos/exports 

yo, personalmente, agrego todos esos export en /etc/profile

Ejecutar el Android-Studio como root me parece demasiado hardcore, pero bueno.

-1
source

In my case, although I configured JDK_HOME and JAVA_HOME, Android Studio did not start.
The problem turned out to be that we do not need to have sudo the t program for it to work. I installed Android Studio in /usr/local and did sudo ./studio.sh to start it, but it complained that it could not find the JAVA_HOME and JDK_HOME variables. But when I installed it in my home folder, it worked without problems without running ./studio.sh .

The problem for the new user may be the understanding that most copy, move and rm operations in /usr/local make it necessary to use sudo , and therefore a person can use sudo ./studio when in usr/local , which is not necessary, and the system looks for the root user configuration JAVA_HOME and JDK_HOME, which it does not find.

+1
source

Open studio.sh and after the lines:

 MKTEMP=`which mktemp` RM=`which rm` CAT=`which cat` TR=`which tr` 

add

 JAVA_HOME=/usr/java/latest 

What is it!

-1
source

Source: https://habr.com/ru/post/945347/


All Articles