Skip to content
Permalink
Browse files

Rework and clarifications.

  • Loading branch information...
Thrameos committed May 29, 2019
1 parent a5cd479 commit 5b1473a3be43cb02012def0503c4fa39866eaab5
Showing with 19 additions and 11 deletions.
  1. +0 −1 .travis.yml
  2. +19 −10 jpype/_core.py
@@ -5,7 +5,6 @@ language: python

python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
@@ -95,12 +95,13 @@ def _hasClassPath(args):

_JVM_started = False

def startJVM(*args, ignoreUnrecognized=False, **kwargs):
def startJVM(*args, **kwargs):
"""
Starts a Java Virtual Machine. Without options it will start
the JVM with the default classpath and jvm. The default classpath
will be determined by ``jpype.getClassPath()``. The default JVM is
determined by ``jpype.getDefaultJVMPath()``.
the JVM with the default classpath and jvmpath.
The default classpath is determined by ``jpype.getClassPath()``.
The default jvmpath is determined by ``jpype.getDefaultJVMPath()``.
Parameters:
*args (Optional, str[]): Arguments to give to the JVM.
@@ -109,10 +110,10 @@ def startJVM(*args, ignoreUnrecognized=False, **kwargs):
Keyword Arguments:
jvmpath (str): Path to the jvm library file,
Typically one of (``libjvm.so``, ``jvm.dll``, ...)
Default of None will use ``jpype.getDefaultJVMPath()``
Using None will apply the default jvmpath.
classpath (str,[str]): Set the classpath for the jvm.
This will override any classpath supplied in the arguments
list. Default will use ``jpype.getClassPath``
list. A value of None will give no classpath to JVM.
ignoreUnrecognized (bool): Option to JVM to ignore
invalid JVM arguments. Default is False.
@@ -145,21 +146,29 @@ def startJVM(*args, ignoreUnrecognized=False, **kwargs):
jvmpath = getDefaultJVMPath()

# Classpath handling
classpath = None
if 'classpath' in kwargs:
if _hasClassPath(args):
if _hasClassPath(args):
# Old style, specified in the arguments
if 'classpath' in kwargs:
# Cannot apply both styles, conflict
raise TypeError('classpath specified twice')
classpath = None
elif 'classpath' in kwargs:
# New style, as a keywork
classpath = kwargs.pop('classpath')
elif not _hasClassPath(args):
else:
# Not speficied at all, use the default classpath
classpath = _classpath.getClassPath()

# Handle strings and list of strings.
if classpath:
if isinstance(classpath, (str, _jtypes._unicode)):
args.append('-Djava.class.path=%s' % classpath)
else:
args.append('-Djava.class.path=%s' %
(_classpath._SEP.join(classpath)))

ignoreUnrecognized = kwargs.pop('ignoreUnrecognized', False)

if kwargs:
raise TypeError("startJVM() got an unexpected keyword argument '%s'"
% (','.join([str(i) for i in kwargs])))

0 comments on commit 5b1473a

Please sign in to comment.
You can’t perform that action at this time.