Different ways to load script on jshell startup

狂风中的少年 提交于 2020-01-04 12:38:40

问题


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:


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:-



来源:https://stackoverflow.com/questions/47868942/different-ways-to-load-script-on-jshell-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!