Highlight for java?


I’m basically writing a website with play framework and I want to turn code snippets to nicely formatted, highlighted html code. Is there any java library on maven that deals with raw code formatting to html like linux command “highlight” does? If there’s no such thing worst case scenario is I can just invoke that command on linux directly.


I personally use google code prettify:


It’s a JavaScript library, very straight forward to use, simply include it on your page, and set the class of your pre element with your Java code in it to prettyprint.

It’s what we use for all the syntax highlighting for the code snippets on playframework.com too. It’s also available as a webjar.

Answered By – James Roper

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.