Text navigation in jdb not working in bash

When I run jdb in bash, the arrow keys create weird junk:

up: ^[[A down: ^[[B left: ^[[D right: ^[[C 

Therefore, I cannot use the command history or correct a spelling error, because I cannot navigate the text at all, which is very annoying. Is there a solution for this?

Java Version Information:

 "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.5) (fedora-68.1.11.5.fc16-x86_64) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode) 

Bash version information:

 GNU bash, version 4.2.28(1)-release (x86_64-redhat-linux-gnu) 
+4
source share
3 answers

Have you tried to launch JLine using JDB?

Is it possible to use JLine as input handler for jdb (java debugger)?

Yes. Try to run:

java jline.ConsoleRunner com.sun.tools.example.debug.tty.TTY args

JLine provides you with cursor interaction and command line history.

+3
source

Have you tried rlwrap ? You can install rlwrap and run

 rlwrap jdb MyMainClass <args> 

instead

 jdb MyMainClass <args> 
+3
source

Following Brian's example of using JLine, this worked quite well.

Finally, I could use up / down to view the history of commands, but it had some disadvantages, such as support for ALT + DEL (for deleting the last word), CTRL + LEFT / RIGHT (for moving the cursor one word back / forward) and CTRL + R (reverse search commands).

Then I found out that such features are offered by JLine2 , so I spent some time on this.

It was a rather painful journey, since I am now on OpenSUSE 12.3, I will not bore you with all the details, but I will talk about them in case you are really interested in this and follow a similar journey:

  • JLine2 is only offered with source (at least on OS12.3), so there is no easy rpm installation
  • This requires maven to create it (which the official OpenSUSE 12.3 repositories do not offer, but, fortunately, there is an unofficial number made for it)
  • Since I am creating it from work, Maven had problems with the proxy server, so I had to provide the proxy data in the /usr/share/maven2/conf/settings.xml file.
  • Then, when I typed " mvn install ", there were problems with several maven project dependencies that I had to download + install manually ("maven-scm-api-1.5.jar", jansi-1.11.jar "and" bsh-2.0b4 .jar ")
  • After that, it was finally created, but had launch problems, but I solved them using the one mentioned here

After that it worked fine, I get most of the privileges that I missed with JLine1, but unfortunately the jdb ">" hint seems to interfere with cursor movement during CTRL + LEFT / RIGHT actions, which is a shame.

I currently get around this by typing CTRL + P and then CTRL + N (this seems to clear the ">" prompt and do all right)

SIDE-NOTE: It was painful for me to enter a large long command to run jdb using jline, so I found it more convenient to run jline2 + jdb through a bash script, for example:

 #!/bin/sh #GI: This is a version of jdb that runs via jline, so that you can up/down through command history # JLINE V1.0 METHOD # ================= #/usr/local/jdk1.6.0_29/bin/java -classpath /usr/share/java/jline.jar:/usr/local/jdk1.6.0_29/lib/tools.jar jline.ConsoleRunner com.sun.tools.example.debug.tty.TTY $* # JLINE V2.* METHOD # ================= /usr/local/jdk1.6.0_29/bin/java -classpath /usr/share/java/jline.jar:/usr/local/jdk1.6.0_29/lib/tools.jar jline.console.internal.ConsoleRunner com.sun.tools.example.debug.tty.TTY $* 

For example, you could run your program through jline + jdb much easier:

 jjdb.sh -classpath './*':'../lib/*' myprogram.MyMainClass 

Ok, hope this helps anyone who pulls a little more. If you need more details on any of my travels, let me know, I keep quite detailed magazines, but just did not want to burden the reader with too detailed information (unless you need it! :))

+1
source

All Articles