Java
Java is a high-level, general-purpose, memory-safe, object-oriented programming language.
In LiveCodes, Java runs in the browser using DoppioJVM.
Usage
Demo:
Communication with JavaScript
The Java code runs in the context of the result page.
A few helper properties and methods are available in the browser global livecodes.java object:
livecodes.java.input: the initial standard input that is passed to the Java code.livecodes.java.loaded: A promise that resolves when the Java environment is loaded. Any other helpers should be used after this promise resolves.livecodes.java.output: the standard output.livecodes.java.error: the standard error.livecodes.java.exitCode: the exit code.livecodes.java.run: a function that runs the Java code with new input. This function takes a string as input and returns a promise that resolves when the Java code is done running. The promise resolves with an object containing theinput,output,error, andexitCodeproperties.
Example:
Language Info
Name
java
Extension
.java
Editor
script
Compiler
Version
DoppioJVM: v0.5.0, which runs Java 8 JDK.
Code Formatting
Using Prettier with the Prettier Java plugin.
Live Reload
By default, new code changes are sent to the result page for re-evaluation without a full page reload, to avoid the need to reload the Java environment.
This behavior can be disabled by adding the code comment // __livecodes_reload__ to the code, which will force a full page reload.
This comment can be added in the hiddenContent property of the editor for embedded playgrounds.
Starter Template
https://livecodes.io/?template=java