Java 8 Nashorn:控制台几乎无法使用 [英] Java 8 Nashorn: Console pretty unusable

查看:231
本文介绍了Java 8 Nashorn:控制台几乎无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OSX 10.9.2上使用Java 8 build 1.8.0-b132。

I am using Java 8 build 1.8.0-b132 on OSX 10.9.2.

我正在使用Nashorn在Java 8中使用新的JavaScript运行时。

I am playing with Nashorn the new JavaScript runtime in Java 8.

我正在使用 Library / Java / JavaVirtualMachines / jdk1.8.0.jdk / Contents / Home / bin / jjs 但遗憾的是由于光标左/右不起作用, jjs 在交互模式下几乎无法使用:

I am using Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/jjs but unfortunately jjs is pretty unusable in interactive mode since cursor left/right does not work:


jjs

jjs> var x = ^ [[D

jjs
jjs> var x =^[[D

以上输出(^ [[D]是'向左光标'按下的结果。有没有办法解决这种行为并在jjs控制台中左/右使用光标?

The above output (^[[D) is the result of pressing 'cursor left'. Is there a way to fix that behavior and using cursor left/right in the jjs console?

推荐答案

感谢@assylias指点我来 rlwrap

Thanks to @assylias for pointing me to rlwrap.

我通过自制软件安装了rlwrap:

I installed rlwrap via homebrew:

brew install rlwrap

然后我在.zshrc中定义了一个别名(对于.bashrc中的bash也是一样的)

Then I defined an alias in my .zshrc (would be the same for bash in .bashrc)

alias jjs='rlwrap /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/jjs'

现在我可以在命令行上使用 jjs ,并且< - 和 - >键按预期工作。

Now I can use jjs on the commandline and the <- and -> keys are working as expected.

这篇关于Java 8 Nashorn:控制台几乎无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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