1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ---------------------------------------------------------------------
|
---|
4 | # IntelliJ IDEA startup script.
|
---|
5 | # ---------------------------------------------------------------------
|
---|
6 | #
|
---|
7 |
|
---|
8 | message()
|
---|
9 | {
|
---|
10 | TITLE="Cannot start IntelliJ IDEA"
|
---|
11 | if [ -t 1 ]; then
|
---|
12 | echo "ERROR: $TITLE\n$1"
|
---|
13 | elif [ -n `which zenity` ]; then
|
---|
14 | zenity --error --title="$TITLE" --text="$1"
|
---|
15 | elif [ -n `which kdialog` ]; then
|
---|
16 | kdialog --error --title "$TITLE" "$1"
|
---|
17 | elif [ -n `which xmessage` ]; then
|
---|
18 | xmessage -center "ERROR: $TITLE: $1"
|
---|
19 | elif [ -n `which notify-send` ]; then
|
---|
20 | notify-send "ERROR: $TITLE: $1"
|
---|
21 | else
|
---|
22 | echo "ERROR: $TITLE\n$1"
|
---|
23 | fi
|
---|
24 | }
|
---|
25 |
|
---|
26 | UNAME=`which uname`
|
---|
27 | GREP=`which egrep`
|
---|
28 | GREP_OPTIONS=""
|
---|
29 | CUT=`which cut`
|
---|
30 | READLINK=`which readlink`
|
---|
31 | MKTEMP=`which mktemp`
|
---|
32 | RM=`which rm`
|
---|
33 | CAT=`which cat`
|
---|
34 | TR=`which tr`
|
---|
35 |
|
---|
36 | if [ -z "$UNAME" -o -z "$GREP" -o -z "$CUT" -o -z "$MKTEMP" -o -z "$RM" -o -z "$CAT" -o -z "$TR" ]; then
|
---|
37 | message "Required tools are missing - check beginning of \"$0\" file for details."
|
---|
38 | exit 1
|
---|
39 | fi
|
---|
40 |
|
---|
41 | OS_TYPE=`"$UNAME" -s`
|
---|
42 |
|
---|
43 | # ---------------------------------------------------------------------
|
---|
44 | # Locate a JDK installation directory which will be used to run the IDE.
|
---|
45 | # Try (in order): IDEA_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
|
---|
46 | # ---------------------------------------------------------------------
|
---|
47 | if [ -n "$IDEA_JDK" -a -x "$IDEA_JDK/bin/java" ]; then
|
---|
48 | JDK="$IDEA_JDK"
|
---|
49 | elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
|
---|
50 | JDK="$JDK_HOME"
|
---|
51 | elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
|
---|
52 | JDK="$JAVA_HOME"
|
---|
53 | else
|
---|
54 | JAVA_BIN_PATH=`which java`
|
---|
55 | if [ -n "$JAVA_BIN_PATH" ]; then
|
---|
56 | if [ "$OS_TYPE" = "FreeBSD" ]; then
|
---|
57 | JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" '^JAVA_HOME' | "$CUT" -c11-`
|
---|
58 | if [ -x "$JAVA_LOCATION/bin/java" ]; then
|
---|
59 | JDK="$JAVA_LOCATION"
|
---|
60 | fi
|
---|
61 | elif [ "$OS_TYPE" = "SunOS" ]; then
|
---|
62 | JAVA_LOCATION="/usr/jdk/latest"
|
---|
63 | if [ -x "$JAVA_LOCATION/bin/java" ]; then
|
---|
64 | JDK="$JAVA_LOCATION"
|
---|
65 | fi
|
---|
66 | elif [ "$OS_TYPE" = "Darwin" ]; then
|
---|
67 | JAVA_LOCATION=`/usr/libexec/java_home`
|
---|
68 | if [ -x "$JAVA_LOCATION/bin/java" ]; then
|
---|
69 | JDK="$JAVA_LOCATION"
|
---|
70 | fi
|
---|
71 | fi
|
---|
72 |
|
---|
73 | if [ -z "$JDK" -a -x "$READLINK" ]; then
|
---|
74 | JAVA_LOCATION=`"$READLINK" -f "$JAVA_BIN_PATH"`
|
---|
75 | JAVA_LOCATION="$JAVA_BIN_PATH"
|
---|
76 | echo $JAVA_BIN_PATH
|
---|
77 | echo $JAVA_LOCATION
|
---|
78 | case "$JAVA_LOCATION" in
|
---|
79 | */jre/bin/java)
|
---|
80 | JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname | xargs dirname` ;;
|
---|
81 | *)
|
---|
82 | JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname` ;;
|
---|
83 | esac
|
---|
84 | echo $JAVA_LOCATION
|
---|
85 | if [ -x "$JAVA_LOCATION/bin/java.exe" ]; then
|
---|
86 | JDK="$JAVA_LOCATION"
|
---|
87 | fi
|
---|
88 | fi
|
---|
89 | fi
|
---|
90 | fi
|
---|
91 |
|
---|
92 | if [ -z "$JDK" ]; then
|
---|
93 | message "No JDK found. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."
|
---|
94 | exit 1
|
---|
95 | fi
|
---|
96 |
|
---|
97 | VERSION_LOG=`"$MKTEMP" -t java.version.log.XXXXXX`
|
---|
98 | "$JDK/bin/java" -version 2> "$VERSION_LOG"
|
---|
99 | "$GREP" 'OpenJDK' "$VERSION_LOG"
|
---|
100 | OPEN_JDK=$?
|
---|
101 | "$GREP" "64-Bit|x86_64" "$VERSION_LOG"
|
---|
102 | BITS=$?
|
---|
103 | "$RM" -f "$VERSION_LOG"
|
---|
104 | if [ $OPEN_JDK -eq 0 ]; then
|
---|
105 | echo "WARNING: You are launching the IDE using OpenJDK Java runtime."
|
---|
106 | echo
|
---|
107 | echo " ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!"
|
---|
108 | echo " SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!"
|
---|
109 | echo
|
---|
110 | echo "NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed"
|
---|
111 | echo " please validate either IDEA_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
|
---|
112 | echo " See http://ow.ly/6TuKQ for more info on switching default JDK."
|
---|
113 | echo
|
---|
114 | echo "Press Enter to continue."
|
---|
115 | # ---------------------------------------------------------------------
|
---|
116 | # COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING
|
---|
117 | # ---------------------------------------------------------------------
|
---|
118 | read IGNORE
|
---|
119 | fi
|
---|
120 | if [ $BITS -eq 0 ]; then
|
---|
121 | BITS="64"
|
---|
122 | else
|
---|
123 | BITS=""
|
---|
124 | fi
|
---|
125 |
|
---|
126 | # ---------------------------------------------------------------------
|
---|
127 | # Ensure IDE_HOME points to the directory where the IDE is installed.
|
---|
128 | # ---------------------------------------------------------------------
|
---|
129 | SCRIPT_LOCATION=$0
|
---|
130 | if [ -x "$READLINK" ]; then
|
---|
131 | while [ -L "$SCRIPT_LOCATION" ]; do
|
---|
132 | SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"`
|
---|
133 | done
|
---|
134 | fi
|
---|
135 |
|
---|
136 | IDE_HOME=`dirname "$SCRIPT_LOCATION"`/..
|
---|
137 | IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"`
|
---|
138 |
|
---|
139 | # ---------------------------------------------------------------------
|
---|
140 | # Collect JVM options and properties.
|
---|
141 | # ---------------------------------------------------------------------
|
---|
142 | if [ -n "$IDEA_PROPERTIES" ]; then
|
---|
143 | IDE_PROPERTIES_PROPERTY="-Didea.properties.file=\"$IDEA_PROPERTIES\""
|
---|
144 | fi
|
---|
145 |
|
---|
146 | MAIN_CLASS_NAME="$IDEA_MAIN_CLASS_NAME"
|
---|
147 | if [ -z "$MAIN_CLASS_NAME" ]; then
|
---|
148 | MAIN_CLASS_NAME="com.intellij.idea.Main"
|
---|
149 | fi
|
---|
150 |
|
---|
151 | VM_OPTIONS_FILE="$IDEA_VM_OPTIONS"
|
---|
152 | if [ -z "$VM_OPTIONS_FILE" ]; then
|
---|
153 | VM_OPTIONS_FILE="$IDE_BIN_HOME/idea$BITS.vmoptions"
|
---|
154 | fi
|
---|
155 |
|
---|
156 | if [ -r "$VM_OPTIONS_FILE" ]; then
|
---|
157 | VM_OPTIONS=`"$CAT" "$VM_OPTIONS_FILE" | "$GREP" -v "^#.*" | "$TR" '\n' ' '`
|
---|
158 | VM_OPTIONS="$VM_OPTIONS -Djb.vmOptionsFile=\"$VM_OPTIONS_FILE\""
|
---|
159 | fi
|
---|
160 |
|
---|
161 | IS_EAP="false"
|
---|
162 | if [ "$IS_EAP" = "true" ]; then
|
---|
163 | OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'`
|
---|
164 | AGENT_LIB="yjpagent-$OS_NAME$BITS"
|
---|
165 | if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
|
---|
166 | AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,sessionname=IdeaIC12"
|
---|
167 | fi
|
---|
168 | fi
|
---|
169 |
|
---|
170 | COMMON_JVM_ARGS="\"-Xbootclasspath/a:$IDE_HOME/lib/boot.jar\" -Didea.paths.selector=IdeaIC12 $IDE_PROPERTIES_PROPERTY"
|
---|
171 | IDE_JVM_ARGS=""
|
---|
172 | ALL_JVM_ARGS="$VM_OPTIONS $COMMON_JVM_ARGS $IDE_JVM_ARGS $AGENT $REQUIRED_JVM_ARGS"
|
---|
173 |
|
---|
174 | CLASSPATH="$IDE_HOME/lib/bootstrap.jar"
|
---|
175 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/extensions.jar"
|
---|
176 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/util.jar"
|
---|
177 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/jdom.jar"
|
---|
178 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/log4j.jar"
|
---|
179 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/trove4j.jar"
|
---|
180 | CLASSPATH="$CLASSPATH;$IDE_HOME/lib/jna.jar"
|
---|
181 | CLASSPATH="$CLASSPATH;$JDK/lib/tools.jar"
|
---|
182 | if [ -n "$IDEA_CLASSPATH" ]; then
|
---|
183 | CLASSPATH="$CLASSPATH;$IDEA_CLASSPATH"
|
---|
184 | fi
|
---|
185 | export CLASSPATH
|
---|
186 | echo $CLASSPATH
|
---|
187 |
|
---|
188 | LD_LIBRARY_PATH="$IDE_BIN_HOME;$LD_LIBRARY_PATH"
|
---|
189 | export LD_LIBRARY_PATH
|
---|
190 |
|
---|
191 | # ---------------------------------------------------------------------
|
---|
192 | # Run the IDE.
|
---|
193 | # ---------------------------------------------------------------------
|
---|
194 | while true ; do
|
---|
195 | eval "$JDK/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME $*
|
---|
196 | test $? -ne 88 && break
|
---|
197 | done
|
---|