Skip to main content

jshell

  • Chapter
  • First Online:
Exploring Java 9
  • 2080 Accesses

Abstract

jshell is a useful utility tool that adds the Read-Eval-Print Loop (REPL) to Java. It allows developers to try Java language features interactively or to evaluate some expressions quickly. For example, it’s common for Java programs to write files to the system’s temporary directory. Sometimes you may want to check the temporary directory to verify the contents of created files. To get the path of the temporary directory, you need to get the value of the Java system property, java.io.tmpdir. You can do this by creating a simple Java program that has a main method to output the value, or you can use the Apache Groovy Console (http://groovy-lang.org/groovyconsole.html) to quickly run the code. But writing another Java program seems like overkill for simple tasks like this, and using Groovy Console requires that you downloaded and install Groovy. Neither approach seems ideal. Now you have a better choice in Java 9—jshell.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 19.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 29.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Fu Cheng

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Cheng, F. (2018). jshell. In: Exploring Java 9. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3330-6_3

Download citation

Publish with us

Policies and ethics