def build_java_ext(self, ext):
    'Run command.'
    java = self.distribution.enable_build_jar
    javac = 'javac'
    try:
        if os.path.exists(os.path.join(os.environ['JAVA_HOME'], 'bin', 'javac')):
            javac = ('"%s"' % os.path.join(os.environ['JAVA_HOME'], 'bin', 'javac'))
    except KeyError:
        pass
    jar = 'jar'
    try:
        if os.path.exists(os.path.join(os.environ['JAVA_HOME'], 'bin', 'jar')):
            jar = ('"%s"' % os.path.join(os.environ['JAVA_HOME'], 'bin', 'jar'))
    except KeyError:
        pass
    if (not java):
        src = os.path.join('native', 'jars')
        dest = os.path.dirname(self.get_ext_fullpath('JAVA'))
        if os.path.exists(src):
            distutils.log.info('Using Jar cache')
            copy_tree(src, dest)
            return
    classpath = '.'
    if ext.libraries:
        classpath = os.path.pathsep.join(ext.libraries)
    distutils.log.info('Jar cache is missing, using --enable-build-jar to recreate it.')
    coverage = self.distribution.enable_coverage
    target_version = '1.8'
    try:
        dirname = os.path.dirname(self.get_ext_fullpath('JAVA'))
        jarFile = os.path.join(dirname, (ext.name + '.jar'))
        build_dir = os.path.join(self.build_temp, ext.name, 'classes')
        os.makedirs(build_dir, exist_ok=True)
        os.makedirs(dirname, exist_ok=True)
        cmd1 = shlex.split(('%s -cp "%s" -d "%s" -g:none -source %s -target %s' % (javac, classpath, build_dir, target_version, target_version)))
        cmd1.extend(ext.sources)
        debug = '-g:none'
        if coverage:
            debug = '-g:lines,vars,source'
        os.makedirs('build/classes', exist_ok=True)
        self.announce(('  %s' % ' '.join(cmd1)), level=distutils.log.INFO)
        subprocess.check_call(cmd1)
        try:
            for file in glob.iglob('native/java/**/*.*', recursive=True):
                if (file.endswith('.java') or os.path.isdir(file)):
                    continue
                p = os.path.join(build_dir, os.path.relpath(file, 'native/java'))
                print('Copy file', file, p)
                shutil.copyfile(file, p)
        except Exception as ex:
            print('FAIL', ex)
            pass
        cmd3 = shlex.split(('%s cvf "%s" -C "%s" .' % (jar, jarFile, build_dir)))
        self.announce(('  %s' % ' '.join(cmd3)), level=distutils.log.INFO)
        subprocess.check_call(cmd3)
    except subprocess.CalledProcessError as exc:
        distutils.log.error(exc.output)
        raise DistutilsPlatformError('Error executing {}'.format(exc.cmd))
Run command.
def build_java_ext(self, ext):
    
    java = self.distribution.enable_build_jar
    javac = 'javac'
    try:
        if os.path.exists(os.path.join(os.environ['JAVA_HOME'], 'bin', 'javac')):
            javac = ('"%s"' % os.path.join(os.environ['JAVA_HOME'], 'bin', 'javac'))
    except KeyError:
        pass
    jar = 'jar'
    try:
        if os.path.exists(os.path.join(os.environ['JAVA_HOME'], 'bin', 'jar')):
            jar = ('"%s"' % os.path.join(os.environ['JAVA_HOME'], 'bin', 'jar'))
    except KeyError:
        pass
    if (not java):
        src = os.path.join('native', 'jars')
        dest = os.path.dirname(self.get_ext_fullpath('JAVA'))
        if os.path.exists(src):
            distutils.log.info('Using Jar cache')
            copy_tree(src, dest)
            return
    classpath = '.'
    if ext.libraries:
        classpath = os.path.pathsep.join(ext.libraries)
    distutils.log.info('Jar cache is missing, using --enable-build-jar to recreate it.')
    coverage = self.distribution.enable_coverage
    target_version = '1.8'
    try:
        dirname = os.path.dirname(self.get_ext_fullpath('JAVA'))
        jarFile = os.path.join(dirname, (ext.name + '.jar'))
        build_dir = os.path.join(self.build_temp, ext.name, 'classes')
        os.makedirs(build_dir, exist_ok=True)
        os.makedirs(dirname, exist_ok=True)
        cmd1 = shlex.split(('%s -cp "%s" -d "%s" -g:none -source %s -target %s' % (javac, classpath, build_dir, target_version, target_version)))
        cmd1.extend(ext.sources)
        debug = '-g:none'
        if coverage:
            debug = '-g:lines,vars,source'
        os.makedirs('build/classes', exist_ok=True)
        self.announce(('  %s' % ' '.join(cmd1)), level=distutils.log.INFO)
        subprocess.check_call(cmd1)
        try:
            for file in glob.iglob('native/java/**/*.*', recursive=True):
                if (file.endswith('.java') or os.path.isdir(file)):
                    continue
                p = os.path.join(build_dir, os.path.relpath(file, 'native/java'))
                print('Copy file', file, p)
                shutil.copyfile(file, p)
        except Exception as ex:
            print('FAIL', ex)
            pass
        cmd3 = shlex.split(('%s cvf "%s" -C "%s" .' % (jar, jarFile, build_dir)))
        self.announce(('  %s' % ' '.join(cmd3)), level=distutils.log.INFO)
        subprocess.check_call(cmd3)
    except subprocess.CalledProcessError as exc:
        distutils.log.error(exc.output)
        raise DistutilsPlatformError('Error executing {}'.format(exc.cmd))