Java2Html - JSPWiki Plugin


JSPWiki Plugin

The java2html.jar file in the download package contains a plugin for the JSPWiki.

The plugin class is: de.java2html.plugin.jspwiki.Java2HtmlPlugin


  1. Copy the java2html.jar file to the lib folder of your JSPWiki installation
    (for example to the folder $TOMCAT_HOME/webapps/JSPWiki/WEB-INF/lib/).
  2. Add the package de.java2html.plugin.jspwiki to the plugin searchpath in the file WEB_INF/
    (for example jspwiki.plugin.searchPath = de.java2html.plugin.jspwiki).
  3. optional: Edit the *.css files in the JSPWiki/templates/default folder to use a smaller font for rendering <CODE>-Elements
    (for example add the line: CODE { font-size: 12px }).
  4. Shutdown and restart tomcat.


There are three alternative ways for using the plugin:
  1. Multi line usage
    Intended for including the Java source code in the wiki text. Example:
    public class HelloWorld {  
      public static void main(String args[]) {
        System.out.println("Hello World!");
    Note that there must be an empty line before the source code.
  2. Attachment reference usage
    Refers to a source code file attached to the current page. Example:
    [{Java2HtmlPlugin attachment=''}]
  3. Url reference usage

    Refers to a source code file given by a http: or file: Url.

    Note: For security reasons this feature is disabled by default. As a file from the given Url is read on the server, this feature could allow people to visualize any file on your server. To enable http or file access you have to add the following lines to your file:

    Example usage:
    [{Java2HtmlPlugin url='file:F:/src/de/java2html/plugin/jspwiki/'}]


There are multiple options available for adjusting the output of the converter:
Parameter Description Example
style Adjusts the output style. The style must be one of the predefined Java2Html styles. Default is Eclipse. style='monochrome'
border boolean flag for rendering a table border around the converted result. Default is false. border='true'
lineNumbers boolean flag for rendering line numbers. Default is false. lineNumbers='true'
tabSize number of spaces representing a tab character. Default is 2. tabSize='4'
alignment Specifies the horizontal alignment of the output. Supported values are left, center, right. Default is left. alignment='center'
printVersion If this property is set the plugin does nothing but printing its name and version number. printVersion='true'

Properties file

In order to specify default options for the Java2Html plugin you can also put a file on the classpath.

I recommend doing so by putting the file into the folder webapps/JSPWiki/WEB-INF/classes/. Don't forget to shutdown and restart Tomcat to activate the changes.

Valid XHTML 1.0!
© Markus Gebhard (, 2000 - 2008
last modified: May 4, 2008