Compiling the OpenCms core

OpenCms provides a source code distribution that you can use to build the OpenCms core. This is only needed if you want to add your own core extensions. To develop the usual kind of website functionality, you should use the OpenCms module mechanism which is much easier to start with and also better documented. Before even considering starting to work on the core, you definitely should have written some OpenCms modules to understand the separation between a module and and a core extension.

The OpenCms core comes with the best possible documentation: The source code itself ;-) This is really not something for the novice Java developer. However, if you have some experience in Java, Java Servlets, JDBC, and XML in general you might take a look. As said before, you should also have already a firm understanding of the OpenCms module API.

Since this is rather deep stuff targeted rather at experts than at beginners, we will not explain every detail of the process. You have been warned.

Step 1: Have Ant installed

Note: In case you are using the Eclipse Platform for development, you don't need an installation of Ant, it is included in Eclipse.

Apache Ant is a Java based build tool. In theory it is kind of like make without make's wrinkles. You need Ant version 1.6 or later to build the OpenCms core. Ant is part of the Jarkarta Apache Project and can be downloaded here. Please check the Ant documentation to make sure you understand the basic principles behind Ant.

Ant installation is described in the Ant manual. It requires that you have set up your path to Java correctly. Make sure Ant runs before proceeding.

Step 2: Get the OpenCms Source distribution

Check out the latest OpenCms source distribution from the CVS repository as described here. It contains all classes necessary to build the OpenCms core. You will then end up with the following structure in your work directory:

/opencms
    /modules            <= Module resources
    /src                <= Start of the OpenCms source tree
    /src-components     <= Component sources (Upload applet, Ant tasks)
    /src-modules        <= Module sources
    /test               <= JUnit test classes
    /webapp             <= Contains the webapp files for Tomcat
    /webapp/WEB-INF/lib <= the necessary libaries
    build.xml           <= This is needed by Ant 

Step 3: Get additional classes (optional)

In case you want to use the Oracle database, you need the Oracle JDBC driver which you can download from the Oracle Technology Network (http://www.oracle.com). You have to register there to get the driver.

The file you need is the JDBC driver called classes12.zip. Place the file in the directory /lib of the OpenCms output folder. If you don't have this file, the OpenCms Oracle Driver (package org.opencms.db.oracle) is not compiled, which is ok if you don't run on Oracle.

Step 4: Build the source by starting Ant

Ok this is the easy part. Call up a commandline, move to the /opencms directory (where the file build.xml resides) of the OpenCms source tree. In your commandline, enter the following:

ant war

That's it! This will build a complete OpenCms distribution. Your work directory will look like this after Ant is finished:

    /opencms               <= Unchanged
    /ExternalComponents    <= Unchanged
    /build
        /classes           <= Will contain the compiled OpenCms classes
        /opencms           <= This is the standard .war directory layout
            /WEB-INF
                /lib
                /oclib
            /META-INF
    /zip                   <= The OpenCms distribution file will be placed here
    /pdf

The final result of the compilation will be a ZIP file which will be placed in the /zip directory. This ZIP is exactly the same layout as the OpenCms binary distributions, so it will contain the opencms.war archive.

Step 5: Install your new version

Now that you have your new OpenCms binary distribution, you simply need to follow the Server installation guide for your server setup. Please make sure you don't mess up any existing installation. Best have a separate machine that is used only for testing and development.

Other Ant targets

There are several more targets in the build.xml that might be useful for you. Here's a short overview:

  • Ant target: war
    This creates the opencms.war, but does not create the binary distribution ZIP file.
  • Ant target: srcdist
    This generates the source distribution ZIP file. Like the one you downloaded in step 2.
  • Ant target: tomcat.dist
    This is useful if you really are in developing core extensions. Provided that OpenCms runs on your machine using Tomcat (and that you have all environment variables set up, esp. TOMCAT_HOME or CATALINA_HOME), calling this target will have Ant updating the OpenCms classes on your machine. This is done by replacing the files in the Tomcat webapps/opencms directory. If you have renamed opencms.war, or if your Tomcat is not installed the usual way, this probably will not work.
  • Ant target: setup
    This is an extension to tomcat.dist: It depends on tomcat.dist, but will also update the OpenCms database, provided you run MySQL on your development machine. This is useful if you do changes to the OpenCms Workplace template files. CAUTION: This drops your complete database without further notice. Don't use until you know what you do.

Latest News

  • OpenCms 17 available

    Apr 9, 2024 - OpenCms 17 gives content managers the new app "Date search" to find content that has been changed in a certain time range. The "Websites" app allows to easily export the content of a complete site for archiving. An option has been added to hide "sensitive" content in the Offline project. The default Mercury template has been further improved, e.g. with SEO optimized job postings, a "spacer" function and marker clusters for maps. OpenCms 17 has also been tested and certified using Java 17 LTS and 21 LTS.

  • OpenCms 17 Release Notes

    Apr 9, 2024 - The OpenCms 17 release notes contain detailed information about the new features and fixes in this version.

  • Alkacon OCEE 17

    Apr 9, 2024 - Alkacon OCEE 17 is the latest OCEE release for OpenCms 17. This version improves the cluster shutdown behaviour when using the CmsShell.

  • OpenCms Docker image

    Apr 9, 2024 - Test OpenCms using the official image from the Docker hub registry - the fastest way to evaluate and test OpenCms. The image is well suited for evaluation and test purposes of the latest OpenCms release. We provide a docker-compose file to get OpenCms and the database running with just one command.

Try the OpenCms Live Demo