<p>I'm working on a command line application for Solaris, written in Java6. I'd like to be able to scroll through a history of previous commands using the up and down arrows like many Unix tools allow (shells, VIM command mode prompt, etc).</p>

<p>Is there any standard way of achieving this, or do I have to roll my own?</p>

[{'answer_id': 49078, 'author': 'Pat Notz', 'author_id': 825, 'author_profile': 'https://Stackoverflow.com/users/825', 'pm_score': 4, 'selected': True, 'text': '<p>Yes, use the <a href="http://tiswww.case.edu/php/chet/readline/rltop.html" rel="nofollow noreferrer">GNU readline</a> library.</p>\n'}, {'answer_id': 49144, 'author': 'SCdF', 'author_id': 1666, 'author_profile': 'https://Stackoverflow.com/users/1666', 'pm_score': 2, 'selected': False, 'text': '<p>I think you are looking for something like <a href="http://jline.sourceforge.net/" rel="nofollow noreferrer">JLine</a> but I\'ve never used it so cannot attest to its quality.</p>\n\n<p>She can apparently deal with autocompletion and command line history, and the last release was recently (feb this year) so it\'s by no means dead.</p>\n'}, {'answer_id': 76992, 'author': 'TREE', 'author_id': 6973, 'author_profile': 'https://Stackoverflow.com/users/6973', 'pm_score': 2, 'selected': False, 'text': '<p>ledit is great on linux for that sort of thing. It\'s probably easily compiled on solaris. </p>\n\n<p>Clarification: ledit wraps the call to your other command line app, and can even be passed a file to persistently store your history. </p>\n\n<p>Here\'s the homepage: <a href="http://cristal.inria.fr/~ddr/ledit/" rel="nofollow noreferrer">http://cristal.inria.fr/~ddr/ledit/</a></p>\n'}, {'answer_id': 77676, 'author': 'rjray', 'author_id': 6421, 'author_profile': 'https://Stackoverflow.com/users/6421', 'pm_score': 1, 'selected': False, 'text': '<p>There is a SourceForge project, <a href="http://java-readline.sourceforge.net/" rel="nofollow noreferrer">http://java-readline.sourceforge.net/</a>, that provides JNI-based bindings to GNU readline. I\'ve played around with it (not used in an actual project), and it certainly covers all of the functionality.</p>\n'}, {'answer_id': 414090, 'author': 'Jason S', 'author_id': 44330, 'author_profile': 'https://Stackoverflow.com/users/44330', 'pm_score': 1, 'selected': False, 'text': '<p>warning: <a href="http://tiswww.case.edu/php/chet/readline/rltop.html" rel="nofollow noreferrer">GNU readline</a> is subject to GPL licensing terms:</p>\n\n<blockquote>\n  <p>Readline is free software, distributed\n  under the terms of the GNU General\n  Public License, version 2. This means\n  that if you want to use Readline in a\n  program that you release or distribute\n  to anyone, the program must be free\n  software and have a GPL-compatible\n  license. If you would like advice on\n  making your license GPL-compatible,\n  contact licensing@gnu.org.</p>\n</blockquote>\n\n<p>In other words, use of Readline spreads the GPL-ness from a library to the entire program. (Contrast with LGPL, which allows runtime linking to a library, and requires open-sourcing only for improvements to the library itself.)</p>\n\n<p>For those of us in the commercial world, even if we\'re not developing commercial applications, this is a show-stopper. </p>\n\n<p>Anyway, <a href="http://en.wikipedia.org/wiki/GNU_readline" rel="nofollow noreferrer">the wikipedia page</a> lists several alternatives, including JLine, which sounds promising.</p>\n\n<p>Just as an aside: I work for a company that designs medical products. We make zero (0) dollars off of PC software. Nearly all our software runs on the embedded systems that we design (and we don\'t make any money off sales/upgrades of this software, only the products themselves); sometimes we do have software diagnostic tools that can run on the end-users\' PCs. (design/manufacture/test software that\'s not released to customers I would think might be possible to use GPL libraries but I\'m not sure) Medical products have fairly tight controls; you basically have to prove to the FDA that it\'s safe for users, it\'s not like the end user can decide "oh, I don\'t like this software, I\'ll just tweak it or use company XYZ\'s aftermarket replacement" -- that would leave device manufacturers open to a huge liability.</p>\n'}]
['https://Stackoverflow.com/questions/49075', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/826/']