The cross-referencing API is pretty basic. You can generate xref for a given Java package or single Java source class. The whole generated file is xref'd by line number.
JXR handles several options like an input/output encoding. See the API for more information.
JXR jxr = new JXR(); jxr.setDest( "/target/jxr" ); jxr.setLog( new DummyLog() ); jxr.xref( Collections.singletonList( "/src/main/java/" ), "templateDir", "WindowsTitle", "DocTitle", "Bottom" );
Note: the templateDir is a directory with several Velocity templates. Maven JXR uses its own templates.
The generated JXR structure should be like the following:
/target/jxr |- allclasses-frame.html |- index.html |- overview-frame.html |- overview-summary.html ...
You can transform a single Java source file with the following:
File sourceFile = new File( "/src/main/java/Test.java" ); PackageManager packageManager = new PackageManager( new DummyLog(), new FileManager() ); JavaCodeTransform codeTransform = new JavaCodeTransform( packageManager ); codeTransform.transform( sourceFile.getAbsolutePath(), "/target/jxr/Test.html", Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", "", "" );