在Mac上使用Oracle Java VM进程内 [英] Using Oracle Java VM in-process on Mac

查看:122
本文介绍了在Mac上使用Oracle Java VM进程内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的后续行动.

MacOS X在/usr/bin下具有java命令.如果有人从Oracle安装JRE,那将不起作用-声称没有Java运行时,并提供下载和安装Apple的运行时.但是,如果您第一次运行

MacOS X has the java command under /usr/bin. If one installs the JRE from Oracle, it doesn't work - claims there's no Java runtime, and offers to download and install Apple's runtime. But if you first run

export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

然后java会按预期工作.这就是Oracle JRE自身安装的地方.

then java works as expected. That's where Oracle JRE installs itself.

现在,我想在过程中使用Oracle Java VM,但我不能-即使设置了JAVA_HOME,也会弹出您需要Java运行时"错误消息.

Now I'd like to use the Oracle Java VM in-process, and I can't - the "You need Java runtime" error message keeps popping up, even with JAVA_HOME being set.

链接到JavaVM框架会导致应用启动时出现消息,甚至在main()之前.

Linking against the JavaVM framework causes the message on app startup, even before main().

尝试动态加载/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/server/libjvm.dylib并调用JNI_CreateJavaVM会导致在方法调用期间出现相同的消息.

Trying to dynamically load /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/server/libjvm.dylib and invoke JNI_CreateJavaVM causes the same message during the method call.

毕竟,java命令以某种方式执行了此操作.我在调试器中四处摸索,它确实会在某个时候调用JNI_CreateJavaVM.我什至模仿了参数(还有一个额外的参数,-Dsun.java.launcher=SUN_STANDARD),没有任何区别.

the java command does it somehow, after all. I've poked around with a debugger, it does invoke JNI_CreateJavaVM at some point. I've even mimicked the arguments (there's one extra one, -Dsun.java.launcher=SUN_STANDARD), it didn't make any difference.

推荐答案

此处找到答案.

代替加载libjvm.dylib,需要加载/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib.它也导出JNI_CreateJavaVM.呼叫它,它将按预期工作.

Instead of loading libjvm.dylib, one needs to load /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib. It exports JNI_CreateJavaVM, too. Call that one, and it'll work as expected.

即使未设置JAVA_HOME也可以正常工作.

Works even with JAVA_HOME not being set.

未来警告:Oracle表示,自Java 1.9起,将不再支持浏览器插件技术.考虑到这一点,Oracle JRE 1.9版的主目录可能不再位于Internet Plug-Ins下.

Future warning: Oracle says that since Java 1.9, the browser plugin technology will no longer be supported. With that in mind, Oracle JRE's home in version 1.9 might not be under Internet Plug-Ins anymore.

这篇关于在Mac上使用Oracle Java VM进程内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆