How to add imports to groovysh on startup?

不羁岁月 提交于 2019-12-22 06:34:03

问题


I'm working on a project where I'd like users to experiment with Java classes on Groovysh. I'd like to make it convenient for them and want to import certain packages by default, when groovysh starts up so that users would not have to re-type the same imports every time they start the shell. Does anyone know how to accomplish this?

Thanks in advance, igor


回答1:


You can add the imports to $HOME/.groovy/groovysh.rc




回答2:


From http://groovy.codehaus.org/Groovy+Shell:

This script, if it exists, is loaded when the shell starts up:

$HOME/.groovy/groovysh.profile

This script, if it exists, is loaded when the shell enters interactive mode:

$HOME/.groovy/groovysh.rc

Edit-line history is stored in this file:

$HOME/.groovy/groovysh.history


来源:https://stackoverflow.com/questions/3041907/how-to-add-imports-to-groovysh-on-startup

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