0

The doc says:

Remember that the startup scripts are loaded into the current session only when the state is reset. The contents of the script is stored, not a reference to the script.

(https://docs.oracle.com/javase/9/jshell/scripts.htm#JSHEL-GUID-AC2A6582-6A9A-48B1-ABBF-4C9536CDFD07)

For example,

/set start -retain mystartscript.jsh

But where does it store the contents of mystartscript.jsh?

nawK
  • 693
  • 1
  • 7
  • 13
  • 1
    The answer to this would mostly be in the direction that the Jshell tool supports such customization using the `Feedback` object(internal class) that a user would modify using the flags on the command line. – Naman Feb 05 '18 at 13:18
  • @nullpointer How did you find this out? – nawK Feb 05 '18 at 13:25
  • 2
    Looking into the code of JDK. – Naman Feb 05 '18 at 13:30
  • I don't want to manually set a list of classpaths upon startup, so I was trying to locate a .jshellrc file somewhere. – nawK Feb 05 '18 at 13:42
  • Do you mean to set up a default classpath to be used while starting up a jshell? – Naman Feb 05 '18 at 13:43
  • Yes, that's what I am trying to do. – nawK Feb 05 '18 at 13:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164562/discussion-between-nawk-and-nullpointer). – nawK Feb 05 '18 at 13:45

1 Answers1

0

Using a relative filename like you do in your example:

/set start -retain mystartscript.jsh

JShell would look for mystartscript.jsh in [user.home]/mystartscript.jsh

You could also give it an absolute file path:

/set start -retain /my_custom_jshell_scripts/mystartscript.jsh

Robert Field—the JShell lead architect—explains in this tutorial how to (re)set/unset JShell's built-in DEFAULT startup scripts plus custom .jshstartup scripts.

deduper
  • 1,944
  • 9
  • 22