2
$\begingroup$

I am playing with JLink in Mathematica. I created a simple Java(Kotlin) Class HelloKT like this:

class HelloKT(words: String) {
    var words: String = words
    fun greets() {
        System.out.println("hello ${words}")
        System.out.flush()
    }
}

I added JDK and Kotlin runtime into classpath by AddToClassPath. It seems to work. Only thing is the System.Out.println(or print in Kotlin) doesn't seem to flush. Wonder if this is a feature or a bug?

i.e.

ShowJavaConsole[]

Then:

h@greets[]
System`out@println[]  (* this works *)

Meanwhile:

 h@greets[] (* this won't output anything in the Java console, until some outside println function call from mathematica flushed them out. *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.