
javarepl.examples.EmbedInApplication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.examples;
import javarepl.console.ConsoleConfig;
import javarepl.console.SimpleConsole;
import javarepl.console.commands.EvaluateFromHistory;
import javarepl.console.commands.ListValues;
import javarepl.console.commands.SearchHistory;
import javarepl.console.commands.ShowHistory;
import javarepl.console.rest.RestConsole;
import java.io.File;
import java.util.Date;
import static java.lang.System.getProperty;
import static javarepl.Result.result;
import static javarepl.console.ConsoleConfig.consoleConfig;
/**
* Example shows how to embed JavaREPL inside your application. Note that your application needs to be running via JDK
* for the JavaREPL to work.
*/
public class EmbedInApplication {
public static void main(String... args) throws Exception {
ConsoleConfig config = consoleConfig()
.historyFile(new File(getProperty("user.home"), ".javarepl-embedded.history"))
.commands(
ListValues.class,
ShowHistory.class,
EvaluateFromHistory.class,
SearchHistory.class)
.results(
result("date", new Date()),
result("num", 42));
new RestConsole(new SimpleConsole(config), 8001);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy