I'd like them to be easy to bundle, with few dependencies and easy to use.
Asked
Active
Viewed 1.4k times
5 Answers
8
Do you want to highlight Java code or use a Java lib to highlight some other code?
I use these two: https://jhighlight.dev.java.net/ (server-side) for xml and http://code.google.com/p/syntaxhighlighter/ (js lib) for other stuff. The latter has something called 'brushes' which are "pluggable" .js for several langauges. If you are doing simple highlighting, I recommend the ,js approach.

Miguel Ping
- 18,082
- 23
- 88
- 136
-
Apparently the syntaxhighligher js library is now located at http://alexgorbatchev.com/SyntaxHighlighter/ – Jason Webb Dec 09 '10 at 22:39
-
If you want server side simple highlighting, there are Java ports of syntaxhighlighter and of prettify. Have a look at my approach https://groups.google.com/forum/#!topic/java-prettify/AANTzgRe81k – Jmini Nov 12 '13 at 18:38
-
The first link is broken. – cristid9 May 20 '17 at 12:48
-
1There is https://github.com/codelibs/jhighlight. Don't know for sure that it's the same project as https://jhighlight.dev.java.net/. – Robert Fleming Mar 05 '18 at 21:41
2
A little update, as we were recently looking for highlighting lib, we found the very good Jygments : http://code.google.com/p/jygments/ .
Available for Ant/Maven/SBT projects throught threecrickets repo, it's a Java port of Pygments ( http://pygments.org ), working for several major languages.

cchantep
- 9,118
- 3
- 30
- 41
1
RSyntaxTextArea is worked for meHere
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
RTextScrollPane rs = new RTextScrollPane(textArea);

stack questions
- 39
- 8