3

According to the jshell documentation:

An alternative to editing at the command prompt is to use an external editor. This editor can be used to edit and create snippets, and is especially helpful for multiline snippets. You can configure JShell to use the editor of your choice.

So to implement this, i use the following commands:

jshell> /set editor sublime
|  Editor set to: sublime

And then, i tried to edit a snippet as follows:

jshell> /edit printName
|  Edit Error: process IO failure: Cannot run program "subllime": error=2, No such file or directory

But, i got the above error. So is it the right way to set editor or something else is required? I also tried to set Microsoft Word as the editor and specified the exact application path from the Application folder of Mac as follows:

jshell> /set editor /Users/karan.verma/Applications/Microsoft Word.app
|  Editor set to: /Users/karan.verma/Applications/Microsoft Word.app

Even, when i set the editor as "atom", i got the same results:

jshell> /set editor atom
|  Editor set to: atom

But still it shows the same error. Any help?

KayV
  • 12,987
  • 11
  • 98
  • 148
  • Plus one for the specific editors. Just try(assuming you have Atom installed) `/set editor atom` or `/set editor vi` these shall work. – Naman Dec 18 '17 at 10:57
  • Try `/set editor "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"` or `/set editor subl` if `subl` is already in the `PATH` – Bless Dec 18 '17 at 11:00
  • @Bless For me at least, these result in the same error as in the question. – Naman Dec 18 '17 at 11:04
  • @nullpointer even it did not worked for atom... Editing the question for the same. – KayV Dec 18 '17 at 11:47
  • @KayV Editing the question with operating system tag, I am though pretty sure this is not java-9, jshell specific. I've seem similar issues previously with git as well. Its the application recognition within your OS. for e.g if I simply type `atom` on my terminal, Atom opens up but the same doesn't work for Sublime. That seems to me the cause of why jshell is not able to open the Sublime editor for me at least. And you didn't come back with vim editor result, does that work fine? – Naman Dec 18 '17 at 11:54
  • @nullpointer @KayV Just tried on my mac. Can confirm that `/set editor subl -w` works for me. Can you check if `sublime` or `subl` is in the `PATH`? Also, does running `"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"` directly on the terminal start Sublime Text? – Bless Dec 18 '17 at 15:21

5 Answers5

2

Mightn't have worked for the OP. But worked for me. So, posting it here hoping it helps someone.

If you can type subl on a terminal and if Sublime Text opens (means subl is in PATH), try:

/set editor subl -w

If Sublime Text doesn't open on typing subl on terminal, but running "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" does open Sublime Text (means subl is not in PATH), try:

/set editor "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" -w

-w flag is to wait for the files to be closed in Sublime Text before returning.

Bless
  • 5,052
  • 2
  • 40
  • 44
0

It worked for me by supplying the full path to the sublime executable. E.g on Windows.

jshell> /set editor c:\sublime3\sublime_text.exe

0

You can specify jshell editor via JSHELLEDITOR user/system variable

MagGGG
  • 19,198
  • 2
  • 29
  • 30
0

In Windows set full path:

   jshell> /set editor C:\Program Files\Notepad++\notepad++.exe

Please do not include inverted commas(" ") in path In MacOs use inverted commas with path.

helvete
  • 2,455
  • 13
  • 33
  • 37
-1

Even i faced same problem as i was giving command

jshell > /set editor "/Applications/Sublime Text.app"

but what's missing is the exact path to bin directory in content folder of sublime.

Solution:

jshell > /set editor "/Applications/SublimeText.app/Contents/SharedSupport/bin/subl"

Try this it will work 100%.