在jshell启动时加载脚本的不同方法 [英] Different ways to load script on jshell startup

查看:78
本文介绍了在jshell启动时加载脚本的不同方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档

还有一个在启动时加载脚本的选项,包括一些特殊的预定义选项.这些是使用–startup标志指定的,传递的是文件名或以下之一:

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 –加载默认行为.就像完全没有指定一样

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

JAVASE –默认情况下导入所有Java SE软件包

JAVASE – Imports all Java SE packages by default

打印–定义要使用的功能print,println和printf

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

但是,当我使用DEFAULT,JAVASE或PRINTING选项启动jshell时,在所有情况下我都可以导入类似的类.

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

例如,JAVASE中涉及的主要软件包是java.lang,java.security等,也可以在其他选项中使用.请找到下面的快照:

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?

推荐答案

断言的方法在您的过程中不正确.区分这些预定义脚本的正确方法是使用

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.

例如:-

这篇关于在jshell启动时加载脚本的不同方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆