:return: If ``blocking=True``, then return a tuple ``(stdout, stderr)``, containing the stdout and stderr outputs generated by the java command if the ``stdout`` and ``stderr`` parameters were set to ``subprocess.PIPE`` or None otherwise. In this case, the return value is the ``Popen`` object, and not a ``(stdout, stderr)`` tuple. :param blocking: If ``false``, then return immediately after spawning the subprocess.
Additionally, stderr can be ``subprocess.STDOUT``, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout. With None, no redirection will occur the child's file handles will be inherited from the parent. ``subprocess.PIPE`` indicates that a new pipe to the child should be created.
Valid values are ``subprocess.PIPE``, an existing file descriptor (a positive integer), an existing file object, 'pipe', 'stdout', 'devnull' and None. :type classpath: str :param stdin, stdout, stderr: Specify the executed programs' standard input, standard output and standard error file handles, respectively.
:type cmd: list(str) :param classpath: A ``':'`` separated list of directories, JAR archives, and ZIP archives to search for class files. Typically, the first string will be the name of the java class and the remaining strings will be arguments for that java class. :param cmd: The java command that should be called, formatted as a list of strings. If java has not yet been configured, it will be configured by calling ``config_java()`` with no arguments. split () _java_options = list ( options ) def java ( cmd, classpath = None, stdin = None, stdout = None, stderr = None, blocking = True ): """ Execute the given java command, by opening a subprocess that calls Java. :type options: list(str) """ global _java_bin, _java_options _java_bin = find_binary ( "java", bin, env_vars =, verbose = verbose, binary_names =, ) if options is not None : if isinstance ( options, str ): options = options. If no options are specified, then do not modify the options list. A common value is ``'-Xmx512m'``, which tells Java binary to increase the maximum heap size to 512 megabytes. :type bin: str :param options: A list of options that should be passed to the Java binary when it is called. If not specified, then nltk will search the system for a Java binary and if one is not found, it will raise a ``LookupError`` exception.
:param bin: The full path to the Java binary.
# Natural Language Toolkit: Internal utility functions # Copyright (C) 2001-2020 NLTK Project # Author: Steven Bird # Edward Loper # Nitin Madnani # URL: # For license information, see LICENSE.TXT import subprocess import os import fnmatch import re import warnings import textwrap import types import sys import stat import locale from xml.etree import ElementTree # Java Via Command-Line # _java_bin = None _java_options = # add classpath option to config_java? def config_java ( bin = None, options = None, verbose = False ): """ Configure nltk's java interface, by letting nltk know where it can find the Java binary, and what extra options (if any) should be passed to Java when it is run.