octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java VM selection at run time


From: Mike Miller
Subject: Java VM selection at run time
Date: Fri, 7 Dec 2012 18:09:47 -0500

On Fri, Dec 7, 2012 at 2:36 PM, Rik wrote:
> On 12/07/2012 11:10 AM, Michael D. Godfrey wrote:
>> On 12/07/2012 02:05 PM, Rik wrote:
>>> Try setting JAVA_HOME to /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64.
>> I will try that, but of course it will break the next time java is updated,
>> Is there a more persistent way
> Probably.  It's just going to take a while because this is so complicated.
>
> One thing to do would be to do an all out search for a Java run-time
> environment.  If we could at least find that then we could use the
> following Java code to find JAVA_HOME.

On a related note, can the Java experts here say whether it will be
possible to select any arbitrary JVM at run time eventually? Is the
JNI stable enough and standardized enough that any modern JVM should
work, or that we should at least be able to detect at run time whether
it has some set of features that Octave requires?

In code, will we be able to do something like the following?

  std::string jvm_lib_path = octave_env::getenv ("JAVA_HOME");
  if (jvm_lib_path.empty ())
    {
      jvm_lib_path = JAVA_HOME;
    }

  std::string java_vm = octave_env::getenv ("JAVA_VM");
  if (java_vm.empty ())
    {
      java_vm = "server";
    }

  jvm_lib_path += std::string ("/jre/lib/") + JAVA_ARCH + "/" +
java_vm + "/libjvm.so";

I went ahead and tested this to see whether it works as is. Out of 5
different JVMs installed on my system, 2 work and 3 segfault for me.
With Octave compiled against openjdk, the openjdk "server" and "zero"
VMs work. The openjdk "cacao" and "jamvm" VMs segfault, as well as the
gcj JVM.

If this is indeed desired, and I think it should be, I can keep
looking or at least file a bug to track the issue.

--
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]