Skip to content

Commit

Permalink
Prepend jre\bin folder to Windows search path before loading JVM.
Browse files Browse the repository at this point in the history
This should fix issue #49.
  • Loading branch information
john-hen committed Oct 18, 2021
1 parent 5b5dca3 commit 5157693
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ def __init__(self, cores=None, version=None, port=None, host='localhost'):
log.debug('Turning off Python fault handlers.')
faulthandler.disable()

# On Windows, prepend the Java folder to the library search path.
# See issue #49.
if platform.system() == 'Windows':
path = os.environ['PATH']
os.environ['PATH'] = str(backend['java']) + os.pathsep + path

# Start the Java virtual machine.
log.debug(f'JPype version is {jpype.__version__}.')
log.info('Starting Java virtual machine.')
Expand Down Expand Up @@ -211,7 +217,7 @@ def __init__(self, cores=None, version=None, port=None, host='localhost'):
try:
java.setPreference(name, value)
except Exception:
log.info(f'Preference {name} does not exist.')
log.info(f'Preference "{name}" does not exist.')

# Log that we're done so the start-up time may be inspected.
log.info('Stand-alone client initialized.')
Expand Down
3 changes: 3 additions & 0 deletions mph/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def search_Windows():
'patch': patch,
'build': build,
'root': root,
'java': java,
'jvm': jvm,
'server': [server],
})
Expand Down Expand Up @@ -277,6 +278,7 @@ def search_Linux():
'build': build,
'root': root,
'jvm': jvm,
'java': java,
'server': [comsol, 'mphserver'],
})

Expand Down Expand Up @@ -367,6 +369,7 @@ def search_macOS():
'build': build,
'root': root,
'jvm': jvm,
'java': java,
'server': [comsol, 'mphserver'],
})

Expand Down

0 comments on commit 5157693

Please sign in to comment.