Skip to content

Instantly share code, notes, and snippets.

@mcupak
Created March 22, 2017 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcupak/d34fc866d89513add705c63f3181a9f2 to your computer and use it in GitHub Desktop.
Save mcupak/d34fc866d89513add705c63f3181a9f2 to your computer and use it in GitHub Desktop.
JShell commands from the live demo of "REPL: Java developer’s new friend" talk at Devoxx US 2017.
2+2
int x = $1 *10
$1 = 10
/vars
/v
System.out.println("hello devoxx")
Thread.sleep(2000)
ZonedDateTime.now()
import java.time.*
ZonedDateTime.now()
/imports
String sayHello(String name){ return "hello "+name;}
sayHello("devoxx")
/m
class HelloPrinter{ public static void sayHello(){ System.out.println("hello devoxx");} }
HelloPrinter.sayHello()
/t
/drop sayHello
/m
/ed HelloPrinter
/open hellohandler.jsh
/list
HttpServer hs = HttpServer.create(new InetSocketAddress(8000),0)
hs.createContext("/hello", new HelloHandler())
hs.start()
/env -class-path guava-21.0.jar
import com.google.common.collect.*
ImmutableSet.of(1,2,3)
Set.of(1,2,3)
$20.getClass()
/history
/save -history jshell-demo.jsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment