JShell 在启动时抛出 StringIndexOutOfBoundsException
JShell throws StringIndexOutOfBoundsException on startup
我正在尝试在 Debian 10 buster 上启动 jshell。我已经从 Oracle 下载 jdk-16_linux-x64_bin.tar.gz 并将其解压到我的主目录中的 'jdk-16' 中。我已经设置了 PATH 和 JAVA_HOME:
~$ export PATH=~/jdk-16/bin:$PATH
~$ export JAVA_HOME=~/jdk-16
~$ javac --version
javac 16
~$ java --version
java 16 2021-03-16
Java(TM) SE Runtime Environment (build 16+36-2231)
Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
测试“Hello world”程序在此环境下可以编译成功运行。但是,当我尝试 运行 jshell 时出现以下错误:
~$ jshell
| Welcome to JShell -- Version 16
| For an introduction type: /help intro
Exception in thread "main" java.io.IOError: java.lang.StringIndexOutOfBoundsException: String index out of range: 5
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:62)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:45)
at jdk.internal.le/jdk.internal.org.jline.keymap.KeyMap.key(KeyMap.java:243)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.key(LineReaderImpl.java:6095)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:179)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.bindKeys(LineReaderImpl.java:6103)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.emacs(LineReaderImpl.java:5813)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.defaultKeyMaps(LineReaderImpl.java:5789)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.<init>(LineReaderImpl.java:293)
at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.<init>(ConsoleIOContext.java:133)
at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.<init>(ConsoleIOContext.java:133)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:978)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 5
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
at java.base/java.lang.String.charAt(String.java:711)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.doTputs(Curses.java:359)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:60)
... 21 more
我也尝试过 jdk-15.0.2,结果相同。 ~/jdk8里面也安装了Java8JDK,不过我觉得不同版本之间不会有什么干扰,因为设置了PATH和JAVA_HOME正确。此错误的原因可能是什么?
原因是 curses 库无法正确初始化,因为我有一个“不寻常”的终端设置(我使用的是 rxvt-unicode-256color)。以下设置
$ export TERM=xterm
已修复错误。
我正在尝试在 Debian 10 buster 上启动 jshell。我已经从 Oracle 下载 jdk-16_linux-x64_bin.tar.gz 并将其解压到我的主目录中的 'jdk-16' 中。我已经设置了 PATH 和 JAVA_HOME:
~$ export PATH=~/jdk-16/bin:$PATH
~$ export JAVA_HOME=~/jdk-16
~$ javac --version
javac 16
~$ java --version
java 16 2021-03-16
Java(TM) SE Runtime Environment (build 16+36-2231)
Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
测试“Hello world”程序在此环境下可以编译成功运行。但是,当我尝试 运行 jshell 时出现以下错误:
~$ jshell
| Welcome to JShell -- Version 16
| For an introduction type: /help intro
Exception in thread "main" java.io.IOError: java.lang.StringIndexOutOfBoundsException: String index out of range: 5
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:62)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:45)
at jdk.internal.le/jdk.internal.org.jline.keymap.KeyMap.key(KeyMap.java:243)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.key(LineReaderImpl.java:6095)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:179)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.bindKeys(LineReaderImpl.java:6103)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.emacs(LineReaderImpl.java:5813)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.defaultKeyMaps(LineReaderImpl.java:5789)
at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.<init>(LineReaderImpl.java:293)
at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.<init>(ConsoleIOContext.java:133)
at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.<init>(ConsoleIOContext.java:133)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:978)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 5
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
at java.base/java.lang.String.charAt(String.java:711)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.doTputs(Curses.java:359)
at jdk.internal.le/jdk.internal.org.jline.utils.Curses.tputs(Curses.java:60)
... 21 more
我也尝试过 jdk-15.0.2,结果相同。 ~/jdk8里面也安装了Java8JDK,不过我觉得不同版本之间不会有什么干扰,因为设置了PATH和JAVA_HOME正确。此错误的原因可能是什么?
原因是 curses 库无法正确初始化,因为我有一个“不寻常”的终端设置(我使用的是 rxvt-unicode-256color)。以下设置
$ export TERM=xterm
已修复错误。