java - Intellij 15 错误 : could not find libjava. dylib

标签 java intellij-idea

我在我的 macOS 中安装了 Intellj 15。运行时会抛出以下错误。

$ /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/MacOS/idea 
2016-05-21 18:07:53.774 idea[1307:51782] Value of IDEA_JDK: (null)
2016-05-21 18:07:53.778 idea[1307:51795] fullFileName is: /Applications/IntelliJ IDEA 15 CE.app/Contents/bin/idea.vmoptions
2016-05-21 18:07:53.778 idea[1307:51795] fullFileName exists: /Applications/IntelliJ IDEA 15 CE.app/Contents/bin/idea.vmoptions
2016-05-21 18:07:53.778 idea[1307:51795] Value of IDEA_VM_OPTIONS is (null)
2016-05-21 18:07:53.778 idea[1307:51795] Processing VMOptions file at /Applications/IntelliJ IDEA 15 CE.app/Contents/bin/idea.vmoptions
2016-05-21 18:07:53.779 idea[1307:51795] Done
Error: could not find libjava.dylib
Failed to GetJREPath()
2016-05-21 18:07:53.779 idea[1307:51795] JNI_CreateJavaVM (/Applications/IntelliJ IDEA 15 CE.app/Contents/jre/jdk) failed: 4294967295

我将 JAVA_HOME 设置为

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/" 

我在 /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/lib/ 中有 libjava.dylib

此外,我在 /Library/Internet\Plug-Ins/JavaAppletPlugin.plugin/ 中有 libjava.dylib

$ ll /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/
total 251384
drwxrwxr-x   2 root  wheel        68 Feb  1 22:02 applet
-rw-rw-r--   1 root  wheel      1378 Dec 22 18:26 calendars.properties
-rw-rw-r--   1 root  wheel   3133473 Dec 22 18:26 charsets.jar
-rw-rw-r--   1 root  wheel     72450 Dec 22 18:26 classlist
drwxrwxr-x   7 root  wheel       238 Feb  1 22:02 cmm
-rw-rw-r--   1 root  wheel      5916 Dec 22 18:26 content-types.properties
-rw-rw-r--   1 root  wheel      4122 Dec 22 18:26 currency.data
drwxrwxr-x  24 root  wheel       816 Feb  1 22:02 deploy
-rw-rw-r--   1 root  wheel   2218758 Dec 22 18:28 deploy.jar
drwxrwxr-x  13 root  wheel       442 Feb  1 22:02 ext
-rw-rw-r--   1 root  wheel      4116 Dec 22 18:26 flavormap.properties
-rw-rw-r--   1 root  wheel      3058 Dec 22 18:26 fontconfig.bfc
-rw-rw-r--   1 root  wheel      8087 Dec 22 18:26 fontconfig.properties.src
drwxrwxr-x  11 root  wheel       374 Feb  1 22:02 fonts
-rw-rw-r--   1 root  wheel     13962 Dec 22 18:26 hijrah-config-umalqura.properties
drwxrwxr-x   3 root  wheel       102 Oct  6  2015 images
-rw-rw-r--   1 root  wheel        55 Dec 22 16:03 javafx.properties
-rw-rw-r--   1 root  wheel    471677 Dec 22 18:28 javaws.jar
-rw-rw-r--   1 root  wheel    114950 Dec 22 18:26 jce.jar
drwxrwxr-x   4 root  wheel       136 Feb  1 22:02 jfr
-rw-rw-r--   1 root  wheel    560452 Dec 22 18:26 jfr.jar
-rw-rw-r--   1 root  wheel     33930 Dec 22 16:03 jfxswt.jar
drwxrwxr-x   3 root  wheel       102 Feb  1 22:02 jli
-rwxrwxr-x   1 root  wheel     15136 Dec 22 18:26 jspawnhelper
-rw-rw-r--   1 root  wheel    633834 Dec 22 18:26 jsse.jar
-rw-rw-r--   1 root  wheel       624 Dec 22 18:26 jvm.cfg
-rw-rw-r--   1 root  wheel      4226 Dec 22 18:26 jvm.hprof.txt
-rw-rw-r--   1 root  wheel     45120 Dec 22 18:26 libAppleScriptEngine.dylib
-rw-rw-r--   1 root  wheel     16068 Dec 22 18:26 libattach.dylib
-rw-rw-r--   1 root  wheel    552948 Dec 22 18:26 libawt.dylib
-rwxrwxr-x   1 root  wheel    721004 Dec 22 18:26 libawt_lwawt.dylib
-rwxrwxr-x   1 root  wheel      9164 Dec 22 18:26 libbci.dylib
-rw-rw-r--   1 root  wheel    186456 Dec 22 18:26 libdcpr.dylib
-rwxrwxr-x   1 root  wheel     62900 Dec 22 16:03 libdecora_sse.dylib
-rw-rw-r--   1 root  wheel    166872 Dec 22 18:28 libdeploy.dylib
-rw-rw-r--   1 root  wheel     25616 Dec 22 18:26 libdt_socket.dylib
-rw-rw-r--   1 root  wheel    419360 Dec 22 18:26 libfontmanager.dylib
-rwxrwxr-x   1 root  wheel    174156 Dec 22 16:03 libfxplugins.dylib
-rw-rw-r--   1 root  wheel    380580 Dec 22 16:03 libglass.dylib
-rwxrwxr-x   1 root  wheel   1185040 Dec 22 16:03 libglib-lite.dylib
-rw-rw-r--   1 root  wheel   1537888 Dec 22 16:03 libgstreamer-lite.dylib
-rw-rw-r--   1 root  wheel    212872 Dec 22 18:26 libhprof.dylib
-rw-rw-r--   1 root  wheel    142392 Dec 22 18:26 libinstrument.dylib
-rw-rw-r--   1 root  wheel     41124 Dec 22 18:26 libj2gss.dylib
-rw-rw-r--   1 root  wheel     15092 Dec 22 18:26 libj2pcsc.dylib
-rw-rw-r--   1 root  wheel     70692 Dec 22 18:26 libj2pkcs11.dylib
-rw-rw-r--   1 root  wheel      8852 Dec 22 18:26 libjaas_unix.dylib
-rw-rw-r--   1 root  wheel    216684 Dec 22 18:26 libjava.dylib
-rw-rw-r--   1 root  wheel     28896 Dec 22 18:26 libjava_crw_demo.dylib
-rwxrwxr-x   1 root  wheel     38524 Dec 22 16:03 libjavafx_font.dylib
-rwxrwxr-x   1 root  wheel    776700 Dec 22 16:03 libjavafx_font_t2k.dylib
-rwxrwxr-x   1 root  wheel    250956 Dec 22 16:03 libjavafx_iio.dylib
-rw-rw-r--   1 root  wheel      8652 Dec 22 18:26 libjawt.dylib
-rw-rw-r--   1 root  wheel    304248 Dec 22 18:26 libjdwp.dylib
-rw-rw-r--   1 root  wheel     25328 Dec 22 18:26 libjfr.dylib
-rw-rw-r--   1 root  wheel    240840 Dec 22 16:03 libjfxmedia.dylib
-rwxrwxr-x   1 root  wheel    214088 Dec 22 16:03 libjfxmedia_avf.dylib
-rwxrwxr-x   1 root  wheel     53104 Dec 22 16:03 libjfxmedia_qtkit.dylib
-rw-rw-r--   1 root  wheel  38159152 Dec 22 16:03 libjfxwebkit.dylib
-rw-rw-r--   1 root  wheel    180468 Dec 22 18:26 libjpeg.dylib
-rw-rw-r--   1 root  wheel     14628 Dec 22 18:26 libjsdt.dylib
-rw-rw-r--   1 root  wheel     15744 Dec 22 18:26 libjsig.dylib
-rw-rw-r--   1 root  wheel     74872 Dec 22 18:26 libjsound.dylib
-rw-rw-r--   1 root  wheel    374428 Dec 22 18:26 libkcms.dylib
-rwxrwxr-x   1 root  wheel    333072 Dec 22 18:26 liblcms.dylib
-rw-rw-r--   1 root  wheel     53576 Dec 22 18:26 libmanagement.dylib
-rw-rw-r--   1 root  wheel    834796 Dec 22 18:26 libmlib_image.dylib
-rw-rw-r--   1 root  wheel     90964 Dec 22 18:26 libnet.dylib
-rw-rw-r--   1 root  wheel     61444 Dec 22 18:26 libnio.dylib
-rw-rw-r--   1 root  wheel    198936 Dec 22 18:28 libnpjp2.dylib
-rw-rw-r--   1 root  wheel     15684 Dec 22 18:26 libnpt.dylib
-rw-rw-r--   1 root  wheel     55364 Dec 22 18:26 libosx.dylib
-rw-rw-r--   1 root  wheel    110948 Dec 22 18:26 libosxapp.dylib
-rw-rw-r--   1 root  wheel     14424 Dec 22 18:26 libosxkrb5.dylib
-rw-rw-r--   1 root  wheel     36068 Dec 22 18:26 libosxui.dylib
-rwxrwxr-x   1 root  wheel     54732 Dec 22 16:03 libprism_common.dylib
-rwxrwxr-x   1 root  wheel     62236 Dec 22 16:03 libprism_es2.dylib
-rwxrwxr-x   1 root  wheel     67968 Dec 22 16:03 libprism_sw.dylib
-rwxrwxr-x   1 root  wheel     10104 Dec 22 18:26 libresource.dylib
-rw-rw-r--   1 root  wheel     77036 Dec 22 18:26 libsaproc.dylib
-rw-rw-r--   1 root  wheel    348848 Dec 22 18:26 libsplashscreen.dylib
-rw-rw-r--   1 root  wheel    161704 Dec 22 18:26 libsunec.dylib
-rw-rw-r--   1 root  wheel    310336 Dec 22 18:26 libt2k.dylib
-rw-rw-r--   1 root  wheel    102100 Dec 22 18:26 libunpack.dylib
-rw-rw-r--   1 root  wheel     49472 Dec 22 18:26 libverify.dylib
-rw-rw-r--   1 root  wheel     36600 Dec 22 18:26 libzip.dylib
-rw-rw-r--   1 root  wheel      2455 Dec 22 18:26 logging.properties
drwxrwxr-x   6 root  wheel       204 Feb  1 22:02 management
-rw-rw-r--   1 root  wheel       381 Dec 22 18:26 management-agent.jar
-rw-rw-r--   1 root  wheel      2107 Dec 22 18:26 meta-index
-rw-rw-r--   1 root  wheel      3070 Dec 22 18:26 net.properties
drwxrwxr-x   5 root  wheel       170 Feb  1 22:02 nibs
-rw-rw-r--   1 root  wheel    944069 Dec 22 18:28 plugin.jar
-rw-rw-r--   1 root  wheel      2796 Dec 22 18:26 psfont.properties.ja
-rw-rw-r--   1 root  wheel     10393 Dec 22 18:26 psfontj2d.properties
-rw-rw-r--   1 root  wheel   3502025 Dec 22 18:26 resources.jar
-rw-rw-r--   1 root  wheel  66604445 Dec 22 18:26 rt.jar
drwxrwxr-x  11 root  wheel       374 Feb  1 22:02 security
drwxrwxr-x   5 root  wheel       170 Feb  1 22:02 server
drwxrwxr-x   3 root  wheel       102 Feb  1 22:02 shortcuts
-rw-rw-r--   1 root  wheel      1210 Dec 22 18:26 sound.properties
-rw-rw-r--   1 root  wheel    102332 Dec 22 18:26 tzdb.dat

我把文件复制到IntelliJ/jre,还是不行。

$ ll /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/jre/jdk/Contents/MacOS/
total 552
-rw-r--r--  1 root  admin  216684 May 21 18:22 libjava.dylib
-rwxr-xr-x@ 1 root  admin   61704 Jan  5 22:29 libjli.dylib

最佳答案

我遇到了完全相同的问题,但启动了另一个版本的应用程序。

当您启动 IntelliJ、Eclipse 等应用程序时,即使您将它们设置为特定的内容,它们也不会使用环境变量。所以设置 JAVA_HOME一个特定的版本根本没有帮助。

您需要检查 MacOS 上的默认 Java 版本是什么。

您可以使用以下方法检查:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (5):
    11.0.1, x86_64: "... 11.0.1"    /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
    9.0.4, x86_64:  "Java SE 9.0.4" /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
    1.8.0_162, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
    1.8.0_152, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
    1.8.0_144, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home

最后一行指向 Java 的默认版本。 所以对我来说,这是指向 JDK 11。 从Jdk9开始,libjava.dylib的位置在 /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/libjava.dylib 下.

这似乎也是broken对于 JDK-12

由于这不适用于默认的 Java 版本,我禁用了 JDK 9 和 11,因此默认版本为 JDK8。

这可以通过重命名 Info.plist 来完成至 Info.plist.disabled<jdk_version>/Contents目录。

sudo mv /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Info.plist /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Info.plist.disabled
sudo mv /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Info.plist /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Info.plist.disabled

/usr/libexec/java_home -V现在再次指向 jdk1.8.0_162 . 该应用程序现在可以正常启动。

关于java - Intellij 15 错误 : could not find libjava. dylib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37368603/

相关文章:

java - Java 1.6 中的 wsimport 内存不足问题

java - IntelliJ maven 项目生成的源未获取(仅部分)

java - 为什么 IntelliJ 告诉我在这种情况下引用不能为空?

java - "java.net.BindException: Address already in use"错误的解决方法?

java - 损坏的 Spring Boot 调试过程 - 忽略断点

java - Java编译器不断说 “error while writing className: className.class (Permission denied)”

java - 'all objects of a type are equal' 模式的代码重用

java - LinkedHashMap 的内部实现与 HashMap 实现有何不同?

java - 使用 IntelliJ 运行 tomcat - 无法启动服务器

java - Android TextView 无效不起作用