Android Studio IDE with private jre/jdk? OSX

后端 未结 5 783
终归单人心
终归单人心 2020-12-18 04:50

I\'m running OSX 10.8 and was trying to run the Android Studio app bundle using a private jdk rather than one that is globally installed.

EDIT: I don\'t have any ja

5条回答
  •  悲&欢浪女
    2020-12-18 05:08

    I just check the executable script that starts android-studio, if you are arleady familiar with intellijIdea it is the same.

      # ---------------------------------------------------------------------
      # Locate a JDK installation directory which will be used to run the IDE.
      # Try (in order): STUDIO_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
      # ---------------------------------------------------------------------
      if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then
        JDK="$STUDIO_JDK"
      elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
        JDK="$JDK_HOME"
      elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
        JDK="$JAVA_HOME"
      else
        JAVA_BIN_PATH=`which java`
        if [ -n "$JAVA_BIN_PATH" ]; then
          if [ "$OS_TYPE" = "FreeBSD" -o "$OS_TYPE" = "MidnightBSD" ]; then
            JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" '^JAVA_HOME' | "$CUT" -c11-`
    

    As written in the comments of the bash scripts, just add a STUDIO_JDK environment variable with the absolute path of the desired JDK.

    This is my ideaj.sh bash script which i stored in /etc/profile.d

    export IDEA_JDK=/opt/jdk1.7.0_71
    export STUDIO_JDK=/opt/jdk1.7.0_71
    

    Add to /etc/bash.bashrc to automatically set the variables at every login.

    source /opt/profile.d/ideaj.sh
    

    All this should be applied to linux, on OS X can be a little different, but the theory is the same.

提交回复
热议问题