4

There are several PHP or js code formatting libs out there -- does anyone know if similar libs exist in Java?

Ie., Given a string of code, return a formatted string with syntax colouring etc.

It'd be ideal if it auto detected the language, but I might be pushing my luck there...

The text will ultimately be displayed within a Flex application, so while I could use a js lib, we'll be parsing large files (up to 6000 lines), so I'd like to keep client side processing minimal.

Ideal output is HTML without CSS, although I'll take what I can get.

0

2 Answers 2

5

That are two distinct tasks. With regard to code formatting, look around using the keyword "java beautifier". Here is a list. I myself have had good experiences with Jalopy which also ships with an Eclipse plugin. With regard to syntax highlighting, it depends on where you'd like to use it. If programmatically, use JHighlight, or if on a webpage, use Prettify (Stackoverflow also uses it and it can detect languages), or as an Eclipse export plugin, use Java2HTML.

Sign up to request clarification or add additional context in comments.

1 Comment

@BalusC Thanks for the info. How can I use java2Html in my own java program. So that which ever java source file I give to it and it produces the formatted HTML ?
1

Perhaps try to see the Colorer Project: http://colorer.sourceforge.net/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.