From 5c0b9609bb8acfbfb06fe4c246ed7acf1c1fc3bf Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 15 Apr 2010 16:25:19 +0400 Subject: [PATCH] IDEA-53694: idea.sh should fallback to JAVA_HOME if JDK_HOME is not set --- bin/nix/idea.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh index f81b8298b51b..486bfd094e2a 100644 --- a/bin/nix/idea.sh +++ b/bin/nix/idea.sh @@ -11,6 +11,19 @@ # --------------------------------------------------------------------- if [ -z "$IDEA_JDK" ]; then IDEA_JDK=$JDK_HOME + if [ -z "$IDEA_JDK" -a -e "$JAVA_HOME/lib/tools.jar" ]; then + IDEA_JDK=$JAVA_HOME + fi + if [ -z "$IDEA_JDK" ]; then + # Try to get the jdk path from java binary path + JAVA_BIN_PATH=`which java` + if [ -n "$JAVA_BIN_PATH" ]; then + JAVA_LOCATION=`readlink -f $JAVA_BIN_PATH | xargs dirname | xargs dirname | xargs dirname` + if [ -x "$JAVA_LOCATION/bin/java" -a -e "$JAVA_LOCATION/lib/tools.jar" ]; then + IDEA_JDK=$JAVA_LOCATION + fi + fi + fi if [ -z "$IDEA_JDK" ]; then echo ERROR: cannot start IntelliJ IDEA. echo No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation