What are the different startup scripts in JShell in Java 9?
JShell is an interactive Java Shell tool that can execute code from JShell and display the output immediately. JShell is a REPL (Read-Evaluate-Print-Loop) tool that can be run from the command line prompt.
In JShell, there is an option to load a script on startup that contains some special predefined options. These options can be specified using the "--startup" flag, passing in a filename or one of DEFAULT, JAVASE, and PRINTING. We can use the "/list -start" command to view all startup code snippets to be evaluated.
- DEFAULT: It loads the default behavior. This is the same as not specifying it at all.
- JAVASE: Imports all Java SE packages by default.
- PRINTING: Define the functions print, println and printf for printing.
In the following code snippet, we can use "DEFAULT" as the startup script.
C:\Users\User>jshell --startup DEFAULT | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> /list -start s1 : import java.io.*; s2 : import java.math.*; s3 : import java.net.*; s4 : import java.nio.file.*; s5 : import java.util.*; s6 : import java.util.concurrent.*; s7 : import java.util.function.*; s8 : import java.util.prefs.*; s9 : import java.util.regex.*; s10 : import java.util.stream.*;
In the following code snippet, we can use "JAVASE" as a startup script.
C:\Users\User>jshell --startup JAVASE | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> /list -start s1 : import java.applet.*; s2 : import java.awt.*; s3 : import java.awt.color.*; s4 : import java.awt.datatransfer.*; s5 : import java.awt.desktop.*; s6 : import java.awt.dnd.*; s7 : import java.awt.event.*; s8 : import java.awt.font.*; s9 : import java.awt.geom.*; s10 : import java.awt.im.*; s11 : import java.awt.im.spi.*; s12 : import java.awt.image.*; s13 : import java.awt.image.renderable.*; s14 : import java.awt.print.*; s15 : import java.beans.*; s16 : import java.beans.beancontext.*; s17 : import java.io.*; s18 : import java.lang.*; s19 : import java.lang.annotation.*; s20 : import java.lang.instrument.*; s21 : import java.lang.invoke.*; s22 : import java.lang.management.*; s23 : import java.lang.module.*; s24 : import java.lang.ref.*; s25 : import java.lang.reflect.*; s26 : import java.math.*; s27 : import java.net.*; s28 : import java.net.spi.*; s29 : import java.nio.*; s30 : import java.nio.channels.*; s31 : import java.nio.channels.spi.*; s32 : import java.nio.charset.*; s33 : import java.nio.charset.spi.*; s34 : import java.nio.file.*; s35 : import java.nio.file.attribute.*; s36 : import java.nio.file.spi.*; s37 : import java.rmi.*; s38 : import java.rmi.activation.*; s39 : import java.rmi.dgc.*; s40 : import java.rmi.registry.*; s41 : import java.rmi.server.*; s42 : import java.security.*; s43 : import java.security.acl.*; s44 : import java.security.cert.*; s45 : import java.security.interfaces.*; s46 : import java.security.spec.*; s47 : import java.sql.*; s48 : import java.text.*; s49 : import java.text.spi.*; s50 : import java.time.*; s51 : import java.time.chrono.*; s52 : import java.time.format.*; s53 : import java.time.temporal.*; s54 : import java.time.zone.*; s55 : import java.util.*; s56 : import java.util.concurrent.*; s57 : import java.util.concurrent.atomic.*; s58 : import java.util.concurrent.locks.*; s59 : import java.util.function.*; s60 : import java.util.jar.*; s61 : import java.util.logging.*; s62 : import java.util.prefs.*; s63 : import java.util.regex.*; s64 : import java.util.spi.*; s65 : import java.util.stream.*; s66 : import java.util.zip.*; s67 : import javax.accessibility.*; s68 : import javax.annotation.processing.*; s69 : import javax.crypto.*; s70 : import javax.crypto.interfaces.*; s71 : import javax.crypto.spec.*; s72 : import javax.imageio.*; s73 : import javax.imageio.event.*; s74 : import javax.imageio.metadata.*; s75 : import javax.imageio.plugins.bmp.*; s76 : import javax.imageio.plugins.jpeg.*; s77 : import javax.imageio.plugins.tiff.*; s78 : import javax.imageio.spi.*; s79 : import javax.imageio.stream.*; s80 : import javax.lang.model.*; s81 : import javax.lang.model.element.*; s82 : import javax.lang.model.type.*; s83 : import javax.lang.model.util.*; s84 : import javax.management.*; s85 : import javax.management.loading.*; s86 : import javax.management.modelmbean.*; s87 : import javax.management.monitor.*; s88 : import javax.management.openmbean.*; s89 : import javax.management.relation.*; s90 : import javax.management.remote.*; s91 : import javax.management.remote.rmi.*; s92 : import javax.management.timer.*; s93 : import javax.naming.*; s94 : import javax.naming.directory.*; s95 : import javax.naming.event.*; s96 : import javax.naming.ldap.*; s97 : import javax.naming.spi.*; s98 : import javax.net.*; s99 : import javax.net.ssl.*; s100 : import javax.print.*; s101 : import javax.print.attribute.*; s102 : import javax.print.attribute.standard.* s103 : import javax.print.event.*; s104 : import javax.rmi.ssl.*; s105 : import javax.script.*; s106 : import javax.security.auth.*; s107 : import javax.security.auth.callback.*; s108 : import javax.security.auth.kerberos.*; s109 : import javax.security.auth.login.*; s110 : import javax.security.auth.spi.*; s111 : import javax.security.auth.x500.*; s112 : import javax.security.cert.*; s113 : import javax.security.sasl.*; s114 : import javax.sound.midi.*; s115 : import javax.sound.midi.spi.*; s116 : import javax.sound.sampled.*; s117 : import javax.sound.sampled.spi.*; s118 : import javax.sql.*; s119 : import javax.sql.rowset.*; s120 : import javax.sql.rowset.serial.*; s121 : import javax.sql.rowset.spi.*; s122 : import javax.swing.*; s123 : import javax.swing.border.*; s124 : import javax.swing.colorchooser.*; s125 : import javax.swing.event.*; s126 : import javax.swing.filechooser.*; s127 : import javax.swing.plaf.*; s128 : import javax.swing.plaf.basic.*; s129 : import javax.swing.plaf.metal.*; s130 : import javax.swing.plaf.multi.*; s131 : import javax.swing.plaf.nimbus.*; s132 : import javax.swing.plaf.synth.*; s133 : import javax.swing.table.*; s134 : import javax.swing.text.*; s135 : import javax.swing.text.html.*; s136 : import javax.swing.text.html.parser.*; s137 : import javax.swing.text.rtf.*; s138 : import javax.swing.tree.*; s139 : import javax.swing.undo.*; s140 : import javax.tools.*; s141 : import javax.transaction.xa.*; s142 : import javax.xml.*; s143 : import javax.xml.catalog.*; s144 : import javax.xml.crypto.*; s145 : import javax.xml.crypto.dom.*; s146 : import javax.xml.crypto.dsig.*; s147 : import javax.xml.crypto.dsig.dom.*; s148 : import javax.xml.crypto.dsig.keyinfo.*; s149 : import javax.xml.crypto.dsig.spec.*; s150 : import javax.xml.datatype.*; s151 : import javax.xml.namespace.*; s152 : import javax.xml.parsers.*; s153 : import javax.xml.stream.*; s154 : import javax.xml.stream.events.*; s155 : import javax.xml.stream.util.*; s156 : import javax.xml.transform.*; s157 : import javax.xml.transform.dom.*; s158 : import javax.xml.transform.sax.*; s159 : import javax.xml.transform.stax.*; s160 : import javax.xml.transform.stream.*; s161 : import javax.xml.validation.*; s162 : import javax.xml.xpath.*; s163 : import org.ietf.jgss.*; s164 : import org.w3c.dom.*; s165 : import org.w3c.dom.bootstrap.*; s166 : import org.w3c.dom.events.*; s167 : import org.w3c.dom.ls.*; s168 : import org.w3c.dom.ranges.*; s169 : import org.w3c.dom.traversal.*; s170 : import org.w3c.dom.views.*; s171 : import org.xml.sax.*; s172 : import org.xml.sax.ext.*; s173 : import org.xml.sax.helpers.*;
In the following code snippet, we can use "PRINTING" as the startup script.
C:\Users\User>jshell --startup PRINTING | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> /list -start s1 : void print(boolean b) { System.out.print(b); } s2 : void print(char c) { System.out.print(c); } s3 : void print(int i) { System.out.print(i); } s4 : void print(long l) { System.out.print(l); } s5 : void print(float f) { System.out.print(f); } s6 : void print(double d) { System.out.print(d); } s7 : void print(char s[]) { System.out.print(s); } s8 : void print(String s) { System.out.print(s); } s9 : void print(Object obj) { System.out.print(obj); } s10 : void println() { System.out.println(); } s11 : void println(boolean b) { System.out.println(b); } s12 : void println(char c) { System.out.println(c); } s13 : void println(int i) { System.out.println(i); } s14 : void println(long l) { System.out.println(l); } s15 : void println(float f) { System.out.println(f); } s16 : void println(double d) { System.out.println(d); } s17 : void println(char s[]) { System.out.println(s); } s18 : void println(String s) { System.out.println(s); } s19 : void println(Object obj) { System.out.println(obj); } s20 : void printf(java.util.Locale l, String format, Object... args) { System.out.printf(l, format, args); } s21 : void printf(String format, Object... args) { System.out.printf(format, args); }
The above is the detailed content of What are the different startup scripts in JShell in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Start Spring using IntelliJIDEAUltimate version...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

When using TKMyBatis for database queries, how to gracefully get entity class variable names to build query conditions is a common problem. This article will pin...
