Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Java applications fail silently on OS X Mavericks

When opening Intelli J or Android Studio after the Mavericks update nothing happens, fails silently.

Java and javac all work from the command line.

Opening the apps from the command line gives this error: LSOpenURLsWithRole() failed with error -10658 for the file /Applications/Android Studio.app.

Opening Intelli J's idea_appLauncher (/Applications/...app/Contents/MacOS/idea_appLauncher) from the command line gave away some more information:

someuser@machine:~$ /Applications/IntelliJ\ IDEA\ 12\ CE.app/Contents/MacOS/idea_appLauncher ; exit; No Java runtime present, requesting install. logout

[Process completed]

Obviosuly Mavericks is not picking up on my Java installation even if it's part of PATH and JAVA_HOME is set and it's not giving the "Please install Java runtime" prompt.

like image 923
Sveinung Kval Bakken Avatar asked Oct 25 '13 16:10

Sveinung Kval Bakken


3 Answers

In my case I saw a similar error but with different error code:

LSOpenURLsWithRole() failed for the application /Applications/IntelliJ IDEA 13 CE.app with error -10810.

This worked for me: just edit the file /Applications/IntelliJ\ IDEA\ 13\ CE.app/Contents/Info.plist and change the key field JVMVersion from 1.6* to 1.7*.

My stack:

  • IntelliJ IDEA 13 CE
  • java version "1.7.0_51"
  • OS X 10.9.1
like image 129
juanmirocks Avatar answered Nov 18 '22 17:11

juanmirocks


Solution:

Download and install the Java Runtime manually.

You also need to enable application from all sources from Settings/Security & Privacy.

like image 9
Sveinung Kval Bakken Avatar answered Nov 18 '22 18:11

Sveinung Kval Bakken


This is due to android studio/intellij is still using the old "JavaLaunching" framework which has deprecated with Java 7. Either you install an End-Of-Life version of JDK 6, or request Android Studio to upgrade to use oracle's JDK appbundle.

I really hate to install a JAVA 6 so I'll have two JDKs on my machine. so I hacked the Android studio files such that they can be launched from the dock:

  1. Change the studio (in /Applications/Android Studio.app/Contents/MacOS) file from a JavaLauncher stub to a shell script, here's how it look like:
#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home`
echo JAVA_HOME=$JAVA_HOME
export APP_PACKAGE='/Applications/Android Studio.app'
exec $JAVA_HOME/bin/java -cp $JAVA_HOME/lib/tools.jar:"$APP_PACKAGE"/lib/bootstrap.jar:"$APP_PACKAGE"/lib/extensions.jar:"$APP_PACKAGE"/lib/util.jar:"$APP_PACKAGE"/lib/jdom.jar:"$APP_PACKAGE"/lib/log4j.jar:"$APP_PACKAGE"/lib/trove4j.jar:"$APP_PACKAGE"/lib/jna.jar -Didea.platform.prefix=AndroidStudio -Didea.paths.selector=AndroidStudioPreview -Dfile.encoding=UTF-8 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Xbootclasspath/a:"$APP_PACKAGE"/lib/boot.jar -XX:MaxPermSize=256m -Xdock:icon="$APP_PACKAGE"/Contents/Resources/AndroidStudio.icns com.intellij.idea.Main

make sure to chmod +x ./studio to it.

  1. Remove the java section in the Info.plist file in the /Applications/Android Studio.app/Contents directory. Otherwise, Apple will still ask you to install JDK 6: edit the file and remove the whole java section. The diff will look like: http://pastebin.com/QS8M45cr
like image 5
Shawn Avatar answered Nov 18 '22 18:11

Shawn