Plugin formating Java source code into syntax highlighted HTML. Source code can be included in the wiki page or referenced from an url.

The plugin can be downloaded from You can also use the jar file attached to this page.

Detailed installation and usage instructions can be found in the documentation.

Sample output of the converter is available at - note that at the moment only the 'Eclipse' style is supported by the plugin.

-- MarkusGebhard, 27-Nov-2003.



Referencing Attachments#

Would be cool to allow that a .java file attached to the page could also be used. For exampe using a protocol type of attachment: (instead of file:). Like so: url=''

W/o having looked at ya code, I guess that this functionality can be achieved by a simple transformation. Assuming that is attached to this page you will have to transform attachment; to to read the source.

If you can read from a file URI, your code should be able to also read from a http URI, not? Well, maybe I over-simplify here...

-- TomZ

Of course http URIs are already working.

To reference the attachment is a great idea. But I think rather than providing a different protocol type I will make this a parameter: Java2HtmlPlugin attachment='' Maybe I will also implement both ways. I guess it should not be hard to get the attachment url prefix from the WikiContext?

A new version (also containing more options for the style etc.) will be released next week.

-- MarkusGebhard

The parameter solution is even ok for me... I am looking forward to the next version. -- TomZ

New release: I have uploaded a new version of the plugin (see attachment).

  • supports the option to refer to an attachment (e.g. ...attachment=''...)
  • supports styles (e.g.'monochrome'..., valid styles are Eclipse (default), Monochrome and Kawa)
  • boolean flag for rendering a table border (...border='true'...)
  • boolean flag for rendering line numbers (...lineNumbers='true'...)

If there are no problems I will release a new official version on my website tomorrow.

BTW: Could this plugin be installed in this wiki? Unfortunately I have no public web server running Tomcat so I cannot demonstrate the features of the plugin :-(


Cool, I will test it tomorrow on my system and provide some feedback here. Concerning the demo, I guess it would be best to send an email directly to Janne asking for it... --TomZ

Sorry guys, anything that allows you to include any file from this server is far, far too dangerous for me to allow on a public wiki. Cool idea, though. --JanneJalkanen

Works on:

  • Java 1.4.1_02
  • Tomcat 4.1.18
  • JSPWiki 2.0.52

Note: For using attachments I had to set the jspwiki.baseURL property, which is commented out by default.


Making a http request to get page attachment is a bad idea. I protected my wiki with container authorization and getting 401 response 'unauthorized' when the plugin tries to download the attachment. I modified the plugin so attchment is read from disk by means of AttachmentManager, but this solutions couples tightly with JSPWiki Api and there is no caching. At least it works.

Please consider resolving this issue. --Mike

Security Concerns#

Many thanks to JanneJalkanen for mentioning security concerns: I almost forgot that.

The new versions have a security manager built in. And here is how it works:

  • referencing an url is disabled by default and leads to a PluginException explaining what to do
  • referencing a http url can be enabled by adding a property to the file: de.java2html.http.url.enabled=true
  • referencing a file url can be enabled by adding a property to the file: de.java2html.file.url.enabled=true
  • other protocols are not supported
  • references to attachments are checked for existence - it will throw a PluginException if the referenced attachment does not exist. So the URL to the attachment should always be valid.

As far as I can see the plugin is now no longer dangerous by default. --MarkusGebhard

New Releases#

2003/12/14: New version 3.6 released.--MarkusGebhard

2004/01/05: New version 4.0 released.--MarkusGebhard


Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
java2html.jar 123.1 kB 7 14-Dec-2003 12:19 MarkusGebhard
« This page (revision-44) was last changed on 26-Sep-2007 23:14 by JanneJalkanen