bugGNU Octave - Bugs: bug #40111, support runtime selection of Java...


bug #40111: support runtime selection of Java with JAVA_HOME on Linux and Unix systems

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Thu 26 Sep 2013 01:07:40 PM UTC  
Category:  Configuration and Build System Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Feature Request
Status:  None Assigned to:  John W. Eaton <jwe>
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Mon 02 Jul 2018 12:22:30 AM UTC, comment #11:

HI folks. Would you mind looking at https://savannah.gnu.org/bugs/index.php?54219 - it adds dynamic JVM detection for macOS and Linux (despite the issue name just saying macOS). It folds in some of the stuff discussed here, adding $JAVA_HOME support.

Andrew Janke <apjanke>
Thu 29 Mar 2018 09:08:40 PM UTC, comment #10:

I think it might be nice / easier to maintain if most of the filesystem logic were written in a .m file function. ov-java.cc could export a simple DEFUN that would accept the full file name of libjvm.so or jvm.dll to use.

See also bug #53389 for the same feature on Windows, would override the Windows registry setting.

The logic for finding the JRE should be something like

Mike Miller <mtmiller>
Project Administrator
Tue 09 Feb 2016 09:18:38 PM UTC, comment #9:

Developers will still need a Java build system including a javac compiler and access to header files like jvm.h. The build system creates a Java library octave.jar which is distributed.

But at runtime the user should only need a JVM and the octave.jar file.

Rik <rik5>
Project Administrator
Tue 09 Feb 2016 07:58:49 PM UTC, comment #8:

I plan to look at this problem soon.

I'm sure I don't understand all the details, but my intent is to fix Octave so that finding the JVM library is done entirely at runtime. I think the only thing we need at build time is a valid jvm.h file.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 04 Feb 2015 06:23:45 AM UTC, comment #7:

What about revising Pascal's patch in comment #4 to use the JAVA_HOME varibale?

Rik <rik5>
Project Administrator
Wed 04 Feb 2015 03:08:53 AM UTC, comment #6:

Hi Pascal, that is certainly one workaround for this problem, but ultimately I think we'd want to dynamically find the libjvm.so, and preferably using the semi-standardized JAVA_HOME environment variable.

On Debian we build with the path /usr/lib/jvm/default-java, for example

This makes it work with whatever the distro selects as the default Java, or in your case, the current version of Java 8, but it doesn't let a user pick a different Java runtime, for whatever reason they may need to do so.

Mike Miller <mtmiller>
Project Administrator
Tue 03 Feb 2015 05:22:27 PM UTC, comment #5:

I compiled octave-3.8.2 on Fedora 21 x86_64. I think I solved the Java issue by not using the full path name of libjvm.so, but a link which will stay constant but be upgraded to the right location with java update.

The technique is to use (under Fedora):

./configure --with-java-includedir=/usr/lib/jvm/java-1.8.0-openjdk/include --with-java-libdir=/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server (other options ...)



Pascal Dupuis <cdemills>
Project Member
Wed 17 Dec 2014 04:45:04 PM UTC, comment #4:

This bug is still present in Fedora 21: after an upgrade of JDK, the java lib cant't be found anymore, up to the next recompilation.

I enclose a small patch adding a fallback mechanism. If loading the jvm lib from the static path fails, try a dynamic path built from the environment variable JAVA_JVM_LIB.



(file #32686)

Pascal Dupuis <cdemills>
Project Member
Mon 30 Sep 2013 06:01:24 PM UTC, comment #3:

The examples are meant to illustrate the logic for finding the jvm, not for copying into configure.ac.

Whether configure.ac is fine as it is?
Yes I'd agree with you, except maybe for Mac OSX; the examples contain some sections devoted to OSX as well.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 30 Sep 2013 12:14:28 AM UTC, comment #2:

Your examples are all for configure scripting. I think Java detection in the configure script is fine as it is. This bug is about overriding the Java path at runtime by setting JAVA_HOME in the shell environment or in octaverc.

Mike Miller <mtmiller>
Project Administrator
Fri 27 Sep 2013 02:06:13 PM UTC, comment #1:

For the automatic way, here are some links (from this thread:



(From what I can see in Octave's configure.ac there's already quite a bit of these implemented.)

I haven't looked whether these configure macros also detect the JVM on 64 bit systemes (where they reside in
...rather than

(and my 'configure proficiency' is lacking anyway)

Philip Nienhuis <philipnienhuis>
Project Member
Thu 26 Sep 2013 01:07:40 PM UTC, original submission:

We currently hardcode the path to the Java runtime (specifically the libjvm.so library) in the Octave interpreter at compile-time. The library is not actually used at compile-time, since it is dlopen'd only when Octave needs it. It would be better if there was an ability for the user to override this path in the Octave interpreter at runtime.

The easiest and most obvious solution would be to keep the hardcoded path as it is now and allow the user's JAVA_HOME environment variable to override it.

More ambitious would be to do some kind of automatic determination of the Java path at runtime, but that's already hard enough as it is in the configure script.

Mike Miller <mtmiller>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #32686:  ov-java.pat added by cdemills (993B - application/octet-stream)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by apjanke (Adding myself to the Cc list)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by cdemills (Updated the item)
  • -email is unavailable- added by mtmiller (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-01 apjanke Carbon-Copy- => Added apjanke
    2018-03-29 mtmiller SummarySupport runtime selection of Java version on Linux and Unix systems => support runtime selection of Java with JAVA_HOME on Linux and Unix systems
    2016-02-18 jwe Assigned toNone => jwe
    2014-12-17 cdemills Attached File- => Added ov-java.pat, #32686
    2014-06-11 mtmiller Dependencies- => bugs #42540 is dependent

    Back to the top

    Powered by Savane 3.3