How to edit files in Confluence JAR files

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

The content on this page relates to platforms that are not supported for Confluence. Consequently, Atlassian can not guarantee providing any support for the steps described on this page. Please be aware that this material is provided for your information only, and that you use it at your own risk.

The files in Confluence JAR files need to be customized. Follow the instructions below.

Solution

In Confluence, many files are contained inside a JAR file. This page tells you how to customize such a file:

  • Extract the contents of the JAR file into a working directory.
  • Edit one of the files extracted from the JAR.
  • Place the updated file in a location which Confluence will recognise. Files in this location will override the version of the file in the JAR.

Note that by using the instructions below, you do not need to bundle the updated file back into the JAR.

About JAR Files

A JAR file is a Java ARchive file. It is similar to a UNIX tar file (or a Windows zip file). To manage a JAR file, you can use the jar command-line tool which is included with the JDK. The jar tool takes several files or an entire directory structure, and compresses them together into a single file. This saves a little space, and makes it much easier to manage that group of files as a single unit. The terms 'file' and 'archive' can be used interchangeably in this context, as they refer to the same collection of bytes.

Customizing a File Contained within a Confluence JAR File

These instructions assume that you already know which JAR file contains the file you need to edit.

To customize a file contained with a JAR:

  1. Shut down Confluence.
  2. Create a new working directory, for example /tmp/confluence-working.
  3. Change directory (cd) to your working directory.
  4. Extract the contents of the JAR:
    jar xf </path/to/file.jar>
    For example, to edit the main Confluence JAR file for Confluence 3.5:

    jar xvf $CONFLUENCE/confluence/WEB-INF/lib/confluence-3.5.jar
    
  5. You now have a directory structure, or at least a set of files, which is the contents of the JAR archive.
  6. Find the file that you need to update, edit the file and save it.
  7. Examine the structure of files and folders in your working directory, which was created when you extracted the content of the JAR.
    • Files in the root level of your structure can be recognized by Confluence if you put them in the /WEB-INF/classes/ folder. For example, if you modify the schedulingSubsystemContext.xml file, you can place it in <confluence install>/confluence/WEB-INF/classes/schedulingSubsystemContext.xml.
    • Files in a subdirectory of your structure need to be placed in a similar subdirectory under <confluence install>/confluence/WEB-INF/classes/. For example, if you modify the fonts/verdanaz.xml file, you must put it in <confluence install>/confluence/WEB-INF/classes/fonts/verdanaz.xml.
  8. Re-compress the contents of the JAR:
    jar uvf </path/to/file.jar>
    For example, to recompress the edited files within the main Confluence JAR file for Confluence 3.5:

    jar uvf $CONFLUENCE/confluence/WEB-INF/lib/confluence-3.5.jar <path to edited file>
  9. Restart Confluence.

Notes

As an alternative to the jar utility, you can extract the JAR file using an unzipping utility like Winzip, 7-zip, Stuffit or the OS X Archive Extractor.

Additionally, text editors such as EMACS and VIM support being able to edit files directly within the .jar without expanding the contents first. 

Related Topics

Installing Patched Class Files
Where are the files that used to be in my Confluence installation directory?

Last modified on Mar 21, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.