"Java" (External Evaluation System)
- Java Version 9.0 and higher is supported.
- Java is a popular general-purpose programming language.
- Java does not require configuration to use with ExternalEvaluate.
- ExternalEvaluate["Java",code] executes the code string in a Java REPL and returns the results as a Wolfram Language expression.
- The following Java built-in types are supported, exactly as they are in J/Link:
byte, char, short, long Integer integer float, double Real real-valued number boolean True|False Boolean values String String sequence of character values Array List array of vaules BigDecimal Real arbitrary-precision real number BigInteger Integer arbitrary-sized integer null Null null value object JavaObject arbitrary Java objects Expr expression arbitrary Wolfram Language expressions
- The Java runtime used by ExternalEvaluate is the same one used for J/Link operations like LoadJavaClass and JavaNew, allowing seamless interoperability between J/Link and ExternalEvaluate.
- Classes made visible to J/Link via its AddToClassPath function are visible to Java code in ExternalEvaluate.
- Java classes you define in ExternalEvaluate are automatically loaded into J/Link and can be used like any other Java classes.
Examplesopen allclose all
Basic Examples (5)
Objects that have no natural representation are returned as JavaObject expressions, just as in J/Link:
Type > and select Java from the drop-down menu to get a code cell that uses ExternalEvaluate to evaluate:
Method definitions return an ExternalFunction object that you can call:
Class definitions return J/Link JavaClass expressions that you can use directly in J/Link:
You can also call your new class directly from ExternalEvaluate: