How do I load Java classes into Python using concise syntax?

These methods import information for use in your queries:

  • importClass(Class classToImport) - Imports a class for use in a query.
  • importStatic(Class classToImport) - Imports the static methods from a class for use in a query.

For example, if you wanted to load the necessary Java classes into Python for BlackScholes, the following example allows you to pull in Java functionality using compact syntax in the query strings:

from deephaven import jpy
from deephaven.TableTools import emptyTable

BS = jpy.get_type("com.illumon.numerics.derivatives.BlackScholes")
db.importClass(BS.jclass)
db.importStatic(BS.jclass)

t = emptyTable(10) \
    .update("FullPath = com.illumon.numerics.derivatives.BlackScholes.price(true, 100, 90, 0.1, 0.01, 0.01, 0.4)") \
    .update("ImportClass = BlackScholes.price(true, 100.0, 90.0, 0.1, 0.01, 0.01, 0.4)") \
    .update("ImportStatic = price(true, 100.0, 90.0, 0.1, 0.01, 0.01, 0.4)")