Different ways to load script on jshell startup

2019-07-11 03:58发布

As per the documentation,

There’s also the option to load a script on startup, including some special predefined options. These are specified using the —startup flag, passing in either a filename or one of:

DEFAULT – load the default behavior. This acts the same as if this is not specified at all

JAVASE – Imports all Java SE packages by default

PRINTING – defines the functions print, println and printf for use

But, when i started the jshell with DEFAULT, JAVASE or PRINTING options, i could import the similar classes in all the cases.

For example, the major packages involved in JAVASE be java.lang, java.security etc, were also available in other options. Please find the bellow snapshot:

kv:micro-tab karan.verma$ jshell --startup JAVASE
|  Welcome to JShell -- Version 9.0.1
|  For an introduction type: /help intro

jshell> import javax.security.
auth   cert   sasl   

jshell> /exit
|  Goodbye
kv:micro-tab karan.verma$ jshell --startup DEFAULT
|  Welcome to JShell -- Version 9.0.1
|  For an introduction type: /help intro

jshell> import javax.security
security   

jshell> import javax.security.
auth   cert   sasl   

jshell> /exit
|  Goodbye
kv:micro-tab karan.verma$ jshell --startup PRINTING
|  Welcome to JShell -- Version 9.0.1
|  For an introduction type: /help intro

jshell> import javax.security.
   ...> 
auth   cert   sasl   

Am I using these options in right manner? Or there is some other meaning of these?

1条回答
趁早两清
2楼-- · 2019-07-11 04:39

The method of assertion is incorrect in your procedure. The correct way to differentiate between those predefined scripts is to use

/list -start

to see what all startup snippets have been evaluated.

For example:-

enter image description here

查看更多
登录 后发表回答