use of jdk.jshell.JShell in project jdk9-jigsaw by AdoptOpenJDK.
the class JShellSample1 method main.
public static void main(String[] args) {
JShell shell = JShell.builder().idGenerator((snippet, integer) -> "MyID" + integer).build();
shell.eval("int a = 100;");
shell.eval("100 + 100;");
shell.variables().forEach(v -> System.out.println(v.typeName() + " " + v.name() + " " + v.id()));
}
use of jdk.jshell.JShell in project jdk9-jigsaw by AdoptOpenJDK.
the class JShellSample3 method main.
public static void main(String[] args) {
JShell shell = JShell.builder().build();
List<SnippetEvent> events = shell.eval("void helloJShell() { System.out.println(\"hello VJUG\"); }");
events.stream().forEach(e -> System.out.println(e.toString()));
}
use of jdk.jshell.JShell in project jdk9-jigsaw by AdoptOpenJDK.
the class JShellSample4 method main.
public static void main(String[] args) {
JShell shell = JShell.builder().build();
List<SnippetEvent> events = shell.eval("int i = 100;");
events.stream().forEach(e -> System.out.println(e.toString()));
}
use of jdk.jshell.JShell in project jdk9-jigsaw by AdoptOpenJDK.
the class JShellSample5 method main.
public static void main(String[] args) throws Exception {
JShell shell = JShell.builder().idGenerator((snippet, integer) -> "My ID " + integer).out(new PrintStream(new FileOutputStream("out.log"), true, "UTF-8")).err(new PrintStream(new FileOutputStream("error.log"), true, "UTF-8")).build();
print(shell.eval("int a = 50;"));
}
use of jdk.jshell.JShell in project jdk9-jigsaw by AdoptOpenJDK.
the class ShellFX method start.
@Override
public void start(Stage primaryStage) throws Exception {
JShell shell = JShell.builder().build();
TextField textField = new TextField();
Button evalButton = new Button("eval");
ListView<String> listView = new ListView<>();
evalButton.setOnAction(e -> {
List<SnippetEvent> events = shell.eval(textField.getText());
events.stream().map(event -> convert(event)).filter(s -> s != null).forEach(s -> listView.getItems().add(s));
});
BorderPane pane = new BorderPane();
pane.setTop(new HBox(textField, evalButton));
pane.setCenter(listView);
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.show();
}
Aggregations