Unable to use Java in Octave

Viewed 6829

I'm using Octave 4.2.1 on Windows 10. When I type in the Octave console:

>> __have_feature__ JAVA
ans = 1

So java is enabled. Using the Command Prompt on Windows I found that I have java version "1.1.0_71". So java is present and running. But when I try to call a java fuction in Octave I get:

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

And when I just type 'java -version':

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

I checked the environment variable for 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. 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.

2 Answers

I suppose you run the 64-bit version of Octave and you have the 64 bit version of JDK 11.0.5

In file octave.vbs write after line

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":

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