🌐
Readthedocs
jpype.readthedocs.io › en › latest › imports.html
JImport — JPype 1.7.2.dev0 documentation
Module for dynamically loading Java Classes using the import system. This is a replacement for the jpype.JPackage(“com”).fuzzy.Main type syntax. It features better safety as the objects produced are checked for class existence.
🌐
Readthedocs
jpype.readthedocs.io › en › latest › quickguide.html
Java QuickStart Guide — JPype 1.7.2.dev0 documentation
The hardest thing about using JPype is getting the jars loaded into the JVM. Java is curiously unfriendly about reporting problems when it is unable to find a jar. Instead, it will be reported as an ImportError in Python. These patterns will help debug problems with jar loading. Once the JVM is started Java packages that are within a top level domain (TLD) are exposed as Python modules allowing Java to be treated as part of Python. ... All java.lang.* classes are available.
🌐
Readthedocs
jpype.readthedocs.io › en › latest › api.html
API Reference — JPype 1.7.2.dev0 documentation
JPype supports several styles of importing. The newer integrated style is provided by the imports module. The older JPackage method is available for accessing package trees with less error checking. Direct loading of Java classes can be made with JClass.
🌐
Readthedocs
jpype.readthedocs.io › en › devel › userguide.html
User Guide — JPype 0.7.0 documentation
To implement an interface contruct a python class and decorate it with annotations @JImplements and @JOverride. from jpype import JImplements, JOverride from java.lang.util import DoubleUnaryOperator # ...
🌐
GitHub
github.com › jpype-project › jpype › blob › master › doc › imports.rst
jpype/doc/imports.rst at master · jpype-project/jpype
Module for dynamically loading Java Classes using the import system. This is a replacement for the jpype.JPackage("com").fuzzy.Main type syntax. It features better safety as the objects produced are checked for class existence.
Author   jpype-project
🌐
Notmyidea
blog.notmyidea.org › using-jpype-to-bridge-python-and-java.html
Using JPype to bridge python and Java - Alexis Métaireau
Once JPype installed (you’ll have to hack a bit some files to integrate seamlessly with your system) you can access java classes by doing something like that: import jpype jpype.startJVM(jpype.getDefaultJVMPath()) # you can then access to the basic java functions jpype.java.lang.System.o...
🌐
GitHub
github.com › jpype-project › jpype › blob › master › jpype › imports.py
jpype/jpype/imports.py at master · jpype-project/jpype
JPype is cross language bridge to allow Python programs full access to Java class libraries. - jpype/jpype/imports.py at master · jpype-project/jpype
Author   jpype-project
🌐
SourceForge
sourceforge.net › home › browse › jpype › discussion
JPype / Discussion / Feedback: Using java classes imported from a jar
For a regular python class (at least for one that is not defined locally in the current script), you use the import statement. Assume a Python module called pymod containing a class called PyClass ... JavaClass = jpype.JClass("javamod.JavaClass") # at this point we have the equivalent of ...
Top answer
1 of 2
7

First of all, I have tested your code on my own jarfile. Indeed, I was presented with such error:

TypeError: Package clip.frontend.Start.main is not Callable

Then, after reading the docs carefully, I've used another method.

import jpype

# I've used other set of parameters to JVM, and modified a bit your classpath setting.
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=clip.jar")

# Second difference, I decided to use JClass because it was more clear for me.
# Parameter array was kept empty.
jpype.JClass("clip.frontend.Start").main([])
jpype.shutdownJVM()

And the output was correct:

% python2 main.py
2 2
+>+[<[>>+>+<<<-]>>[<<+>>-]>[[-]>>>>>>+<<<<<<<<<[-]>[-]>>>>>>>>[<<<<<<<<+>+>>>>>>>-]
<<<<<<<[>>>>>>>+<<<<<<<-]>>>>>>>[-]<<<<<<]<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>>>>>++
[<<<<<+>>>>>>>>>>>>+<<<<<<<-]<<<<<[>>>>>+<<<<<-]>>>>>>>>>>>>>[>>]+<<[<<]>[>[>>]
<+<[<<]>-]<<<<<<<[-]++[<<<<<+>>>>>>>>>>>>+<<<<<<<-]<<<<<[>>>>>+<<<<<-]>>>>>>>>>>>>>
[>>]+<<[<<]>[>[>>]<+<[<<]>-]<<<<<<<[-]#JVM has been shutdown

Now, I decided to translate my solution to match your problem:

import jpype
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=astral.jar")
jpype.JClass("phylonet.coalescent.CommandLine").main([])
jpype.shutdownJVM()

And the code works correctly. More important than the actual solution is the fact, why doesn't your code work. You used wrong set of parameters and specified the classpath in the other way.

Replacing JClass with JPackage, the code still works.

import jpype
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=astral.jar")
jpype.JPackage('phylonet').coalescent.CommandLine.main([])
jpype.shutdownJVM()

As the way you extract classes from classpath is correct, the only possible cause is specifying invalid parameter set. After removing -ea the code still works, so mistake you made lies in this fragment of code.

'-Djava.class.path="%s"' % jar

And in fact, I've used this in opposition to my answer, and bam, the code yields this:

TypeError: Package phylonet.coalescent.CommandLine.main is not Callable

This means, the parameter contained following:

-Djava.class.path="astral.jar"

instead of following

-Djava.class.path=astral.jar

The quotes were misplaced and raised the error in result.

2 of 2
2

This was a classic issue with JPype. If the jar can't be loaded then JPackage will return another JPackage which is not callable. Common causes of a failure to load include

  • The JVM loaded does not support the version of the jar (Check that getDefaultJVMPath() is not some old version)
  • A jar dependency is missing.
  • The JVM could not find the Jar as the specified path.

The previous solution was to use java.lang.Class.forName which would print the diagnostics on the jar loading. Version 0.7.0 which is currently in available as a release candidate has addressed this.

Also it is recommended that you use jpype.imports or JClass rather than JPackage when importing a class. It is much safer as it will report a more meaningful error. For example:

import jpype
import jpype.imports

jpype.startJVM()
jpype.imports.registerDomain('phylonet')  # This is required as phylonet is not a tld

from phylonet.coalescent import CommandLine

You can mark a package as being conforming (Classes start upper, packages are lower) to force an error.

Find elsewhere
🌐
Readthedocs
jpype.readthedocs.io › en › v1.5.0 › imports.html
JImport — JPype 1.5.0 documentation
Module for dynamically loading Java Classes using the import system. This is a replacement for the jpype.JPackage(“com”).fuzzy.Main type syntax. It features better safety as the objects produced are checked for class existence.
🌐
codecentric
codecentric.de › en › knowledge-hub › blog › java-classes-python
How to use Java classes in Python
November 15, 2021 - 1import jpype 2import jpype.imports 3from jpype.types import * 4 5# launch the JVM 6jpype.startJVM(classpath=['../target/autosnake-1.0-SNAPSHOT.jar']) 7 8# import the Java module 9from me.schawe.autosnake import SnakeLogic 10 11# construct an ...
🌐
AskPython
askpython.com › python › examples › call-java-using-python
Calling Java using Python | #1 guide to Jpype
November 8, 2023 - To Install JPype in your system, use the following cmd command: ... from jpype import startJVM, shutdownJVM, java startJVM(convertStrings=False) java.lang.System.out.println("hello world") random = java.util.Random() number1 = random.nextInt(10) ...
🌐
SourceForge
jpype.sourceforge.net › doc › user-guide › userguide.html
JPype 0.4 - User guide
For example, to import the w3c DOM package : Document = JPackage('org').w3c.dom.Document · For convenience, the jpype modules predefines the following JPackages : java, javax · They can be used as is, without needing to resort to the JPackage class.
🌐
AGI
help.agi.com › STKComponentsJava › html › Python.htm
Using DME Component Libraries with Python | DME Component Libraries for Java 2026 r1
By setting this to false, Java strings will not be converted to Python strings when returned from a method. The second parameter, "-ea", enables assertions. Any string arguments that start with a dash will be passed into the JVM as command line flags. ... import jpype # add the class path, where jarFolderFilePath is the filepath to the folder that the jar files are in classpath = jarFolderFilePath + "\*" jpype.addClassPath(classpath) if not jpype.isJVMStarted(): jpype.startJVM('-ea', convertStrings = False )
🌐
GitHub
github.com › jpype-project › jpype
GitHub - jpype-project/jpype: JPype is cross language bridge to allow Python programs full access to Java class libraries. · GitHub
JPype is cross language bridge to allow Python programs full access to Java class libraries. - jpype-project/jpype
Starred by 1.3K users
Forked by 205 users
Languages   Python 47.5% | C++ 36.1% | Java 15.6%
🌐
Readthedocs
jpype.readthedocs.io › en › v0.7.5 › api.html
API Reference — JPype 0.7.5 documentation
Get the full java class path. Includes user added paths and the environment CLASSPATH. JPype supports several styles of importing. The newer integrated style is provided by the imports module. The older JPackage method is available for accessing package trees with less error checking.
🌐
Legendu
legendu.net › misc › blog › call-java-code-using-jpype-from-python
Call Java Code Using JPype from Python
March 31, 2020 - import os import sys from pathlib import Path import jpype jpype.addClassPath("/path/to.jar") jpype.startJVM() print(jpype.java.lang.System.getProperty("java.class.path")) import ...
🌐
DeepWiki
deepwiki.com › jpype-project › jpype › 3-working-with-java-classes
Working with Java Classes | jpype-project/jpype | DeepWiki
April 29, 2025 - Working with Java classes in JPype involves several components that work together: ... Use jpype.imports for Cleaner Code: Enable jpype.imports to use Java classes with simple import statements.