Skip to content

Improve search for JAVA_HOME on Windows #70

@EwoutH

Description

@EwoutH

On 64-bit Windows, NetLogo is installed by default in "C:\Program Files\NetLogo 6.3.0". A Java jvm.dll is with it, located in "C:\Program Files\NetLogo 6.3.0\runtime\bin\server\jvm.dll".

Using pynetlogo on Windows, this jvm.dll isn't found by default. If pynetlogo could look there before throwing an error.

No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.
Traceback (most recent call last):
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\em_framework\experiment_runner.py", line 91, in run_experiment
    model.run_model(scenario, policy)
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\util\ema_logging.py", line 152, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\em_framework\model.py", line 299, in run_model
    super().run_model(scenario, policy)
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\util\ema_logging.py", line 152, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\em_framework\model.py", line 181, in run_model
    self.model_init(policy)
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\util\ema_logging.py", line 152, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\ema_workbench\connectors\netlogo.py", line 134, in model_init
    self.netlogo = pynetlogo.NetLogoLink(
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\pynetlogo\core.py", line 188, in __init__
    jvm_path = jpype.getDefaultJVMPath()
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py", line 74, in getDefaultJVMPath
    return finder.get_jvm_path()
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ewout\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py", line 212, in get_jvm_path
    raise JVMNotFoundException("No JVM shared library file ({0}) "
jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.

The current workaround is adding:

import os
os.environ["JAVA_HOME"] = 'C:/Program Files/NetLogo 6.3.0/runtime/bin/server/'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions