简体   繁体   English

无法在 Octave 中使用 Java

[英]Unable to use Java in Octave

I'm using Octave 4.2.1 on Windows 10. When I type in the Octave console:我在 Windows 10 上使用 Octave 4.2.1。当我在 Octave 控制台中输入时:

>> __have_feature__ JAVA
ans = 1

So java is enabled.所以启用了java。 Using the Command Prompt on Windows I found that I have java version "1.1.0_71".在 Windows 上使用命令提示符我发现我有 java 版本“1.1.0_71”。 So java is present and running.所以java存在并正在运行。 But when I try to call a java fuction in Octave I get:但是当我尝试在 Octave 中调用 java 函数时,我得到:

cp = javaclasspath
error: unable to find Java Runtime Environment: software\javasoft\java runtime environment::Currentversion

And when I just type 'java -version':当我输入“java -version”时:

>> java -version
error: 'java' undefined near line 1 column 1

I checked the environment variable for java:我检查了java的环境变量:

>> getenv JAVA_HOME
ans = C:\Program Files\Java\jdk1.7.0_71

Again, this looks fine.再次,这看起来不错。 FInally I even tried to install Octave from scratch, but this did not solve the issue.最后,我什至尝试从头开始安装 Octave,但这并没有解决问题。 My guess is that it has something to do with the 'software\\javasoft\\java runtime environment::CurrentVersion' but I'm unable to figure out what it is.我的猜测是它与“软件\\javasoft\\java 运行时环境::当前版本”有关,但我无法弄清楚它是什么。

This is likely connected to the difference of the bitness of Octave and your JRE.这可能与 Octave 和您的 JRE 的位数差异有关。 This post raises the same issue. 这篇文章提出了同样的问题。 That one was resolved by bringin the Octave bitness into line with JRE bitness.通过将 Octave 位数与 JRE 位数保持一致来解决这个问题。 Make sure your Octave installation is 64-bit.确保您的 Octave 安装是 64 位。

It is also worth checking you have the following variable specified:还值得检查您是否指定了以下变量: 在此处输入图片说明

I suppose you run the 64-bit version of Octave and you have the 64 bit version of JDK 11.0.5我想您运行的是 64 位版本的 Octave,并且您拥有 64 位版本的 JDK 11.0.5

In file octave.vbs write after line在文件octave.vbs行后写

Set wshShell = CreateObject( "WScript.Shell" )

the line线

wshShell.Environment("SYSTEM")("JAVA_HOME") = "c:\program files\java\jdk-11.0.5"

Then merge the following registry lines with your registry然后将以下注册表行与您的注册表合并

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
"CurrentVersion"="11.0.5"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\11.0.5]
"JavaHome"="C:\\Program Files\\Java\\jdk-11.0.5"
"RuntimeLib"="C:\\Program Files\\Java\\jdk-11.0.5\\bin\\client\\jvm.dll"

*** EDIT: The code above, is for Windows 7. If you run Windows 10, change "client" with "server": *** 编辑:上面的代码适用于 Windows 7。如果您运行 Windows 10,请将“客户端”更改为“服务器”:

    "RuntimeLib"="C:\\Program Files\\Java\\jdk-11.0.5\\bin\\server\\jvm.dll"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM