Results 1 to 5 of 5

Thread: Android Studio and Java JDK

  1. #1

    Default Android Studio and Java JDK

    Trying to get Android Studio to start but I'm getting an error saying JAVA_HOME points to a jre not a jdk, and can't find tools.jar

    Code:
    java -version
    openjdk version "1.8.0_77"
    OpenJDK Runtime Environment (build 1.8.0_77-b03)
    OpenJDK 64-Bit Server VM (build 25.77-b03, mixed mode)

    I installed java-1_8_0-openjdk-devel also, but I'm not sure how to change JAVA_HOME to point to the jdk, and not the jre.

    /usr/lib64/jvm is full of java folders, which just adds to the confusion:

    Code:
    java                      java-1.8.0-openjdk        jre                jre-openjdk
    java-1.7.0-openjdk-1.7.0  java-1.8.0-openjdk-1.8.0  jre-1.8.0
    java-1.8.0                java-openjdk              jre-1.8.0-openjdk
    Which one, and how to I set JAVA_HOME to it?

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,820
    Blog Entries
    15

    Default Re: Android Studio and Java JDK

    Hi
    I wrote a script to start it and export the path;
    Code:
    cat ~/bin/android_studio 
    
    #!/bin/sh
    export JAVA_HOME="/etc/alternatives/java_sdk_openjdk"
    cd ~/data/android/android-studio/bin && exec ./studio.sh $*
    export JAVA_HOME="/usr/lib64/jvm/jre"
    You will need to adjust the path to studio.sh.

    I also created a desktop (aka menu/shortcut item;
    Code:
    cat .local/share/applications/android.desktop
    
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Name=Android Studio
    Comment=Android Studio integration environment tool
    Version=1.0
    Icon=~/.icons/studio.png
    Exec=~/bin/android_studio
    Type=Application
    Terminal=false
    Encoding=UTF-8
    Categories=Development;IDE;
    Again, adjust the Icon path for your setup, you may need to use the full path in Icon and Exec.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: Android Studio and Java JDK

    Quote Originally Posted by malcolmlewis View Post
    Hi
    I wrote a script to start it and export the path;
    Code:
    cat ~/bin/android_studio 
    
    #!/bin/sh
    export JAVA_HOME="/etc/alternatives/java_sdk_openjdk"
    cd ~/data/android/android-studio/bin && exec ./studio.sh $*
    export JAVA_HOME="/usr/lib64/jvm/jre"
    You will need to adjust the path to studio.sh.

    I also created a desktop (aka menu/shortcut item;
    Code:
    cat .local/share/applications/android.desktop
    
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Name=Android Studio
    Comment=Android Studio integration environment tool
    Version=1.0
    Icon=~/.icons/studio.png
    Exec=~/bin/android_studio
    Type=Application
    Terminal=false
    Encoding=UTF-8
    Categories=Development;IDE;
    Again, adjust the Icon path for your setup, you may need to use the full path in Icon and Exec.
    Thanks, I didn't know about the alternatives directory. I'll give this a try, just as a side question, why would you need to change the JAVA_HOME back to the jre? I thought the JDK contains the jre AND the dev tools, so having JAVA_HOME point to the jdk would still allow applications like libreoffice to run properly?

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,820
    Blog Entries
    15

    Default Re: Android Studio and Java JDK

    Quote Originally Posted by Nano_Python View Post
    Thanks, I didn't know about the alternatives directory. I'll give this a try, just as a side question, why would you need to change the JAVA_HOME back to the jre? I thought the JDK contains the jre AND the dev tools, so having JAVA_HOME point to the jdk would still allow applications like libreoffice to run properly?
    Hi
    Yes, I just wanted it back at where I originally started after finishing the testing, try a complete switch and see what happens, if it all works fine it can be removed and placed in your ~/.profile. My preference is per user rather than system wide...
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,273
    Blog Entries
    2

    Default Re: Android Studio and Java JDK

    If you're using openjdk, despite the name it only is the jre.
    The error is saying that you don't have the "jdk" components installed which means that you need to first identify the "openjdk-devel" packages available to you with the following
    Code:
    zypper se openjdk-devel
    Today, the above will likely return two results, one for openjdk-devel version 7 and the other for version 8.
    Install either or both packages displayed
    Code:
    zypper in package1 package2
    In openjdk's case, when you install the "devel" packages, they will automatically link to and extend the functionality of your existing "update-alternatives" options, so you won't see anything different than without the "devel" packages installed. But, you are now ready to select whichever java package you wish if you have multiple java installed (like Oracle Java or different versions of openjdk). When integrated with "update-alternatives" your selected Java should also automatically set the "HOME" environmental variable, no need to set on your own.
    Code:
    update-alternatives --config java
    If you did the above, you shouldn't have a problem.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •