Opening Files quickly in JShell - nus-cs2030/2324-s2 GitHub Wiki
Have you been typing in every single .java file every time you restart JShell? Try these methods to speed up your testing!
Creating a proxy importall.jsh
Instead of manually running imports at each step, you can concatenate all /open commands into a folder. Create afile importall.jsh, containing the following:
/open file1.java
/open file2.java
Do note that the files would have to be listed in bottom-up dependency, similar to how you'd type it in manually in jshell.
When you start jshell, just run /open importall.jsh, and everything should be loaded.
Automatically creating an an importall.jsh
The idea here would be to list all java files in your directory, and add it to a text file. On each line, add a "/open " ahead of what's been written.
This creates an importall.jsh, except that it's in the wrong order. However, we can repeatedly open this file till all files are open.
Let's create the file first:
ls *.java | awk '$0="/open "$0' > temp.jsh
Next, duplicate the lines:
a=$(awk 'END{print NR}' temp.jsh); for run in {1..$a}; do cat temp.jsh >> importall.jsh; done; rm temp.jsh; unset a;
Finally, in JShell:
/open importall.jsh
You're gonna see a TON of errors, but that's okay since the load errors will resolve themselves when the file is loaded again.