Creating a Simple Java Event Calendar

February 8, 2013

This is a detailed tutorial that covers the basic steps of creating a Java event calendar/scheduler using DHTMLX JavaPlanner library.


The calendar can be compiled in any preferred text editor. We have chosen Eclipse IDE to implement the task.


Follow the steps described in the tutorial below to create an attractive and interactive Java event calendar with intuitive drag-and-drop, seamless ajax loading and quickly set up data load and save.


1st Creating a New Project


Note: to create an event calendar, you should have Apache Tomcat installed.


First of all, download and unzip JavaPlanner package.
Open Eclipse and create a new Dynamic web project. Let’s name it JavaPlanner.


2nd Adding Required Java Classes


2.1. Open your project folder on the disc, and copy javaplanner-v1.0.jar into WebContent/WEB-INF/lib/. The folder codebase should be copied to the WebContent folder of your project.


2.2. To add an external JAR, open your project Properties -> Java Build Path -> Add External Jars. Select servlet-api.jar.




2.3. Select Targeted Runtimes in Properties and tick Apache Tomcat.


2.4. Add WEB-INF/lib/scheduler.jar into build path.


2.5. Then create a new JSP file in the WebContent folder. Name it javaplanner.jsp. It will display the calendar in the browser.




It should have the following coding:


2.6.  Now create a new package ‘com.dhtmlx.demo’. To obtain, compile and load data to the event calendar create a new Java class ‘EventsManager’ inherited from ‘com.dhtmlx.planner.DHXEventsManager’.



Modify the class code as follows:

2.7. Create a new JSP file in the WebContent folder. Name it events.jsp and replace the code:

3rd Generating the View

To run the project on the server, right-click on JavaPlanner project -> Run as -> Run on server -> Select Tomcat Server at localhost -> Finish.



Your event calendar has been created. Open your calendar in a browser: http://localhost:8080/JavaPlanner/javaplanner.jsp


You can drag-and-drop, delete the existing events and create new ones but they are not saved after page reload.


4th Setting Up the Database (MySQL)
Let’s enable loading and saving  Java calendar  events from a database.


4.1. First, table ‘events’ needs to be created in your database. Go to your database and create a new SQL query by adding the following code:



4.2. After the table is successfully created, copy mysql-connector-java-5.1.17-bin.jar (download) into WebContent/WEB-INF/lib/ directory from JavaPlanner Package. Add it to Build Path.


4.3. Go to com.dhtmlx.demo to create a new class DatabaseConnection.


Add the following code:


4.4. Configure database connection in as it is shown below:


4.5. At this step modify

4.6. Final amendments are made to WebContent/javaplanner.jsp:


Refresh the project, restart the server and that’s it. Now your calendar events can be saved.




To add more features to the created event calendar check the available documentation. There is also a two-part video that visualizes the entire tutorial.


Check out our other java calendar tutorials:


Creating a web calendar using Spring MVC


Creating a web calendar using Grails


Creating a web calendar using Struts


If you find this tutorial useful, you are welcome to share it with your friends. Fill free to put your comments below.

Comments (51)

  • Olya,

    Was totally stuck until I read this, now back up and runinng.

  • Zhe Zhang,

    How can I make it both multi-resource weekly view? In each day of the week, there will be 5 columns for 5 rooms.

    1. Dmitry,

      Hi, unfortunately there is no way to do show rooms columns in week view.

  • udahya,

    Previously created events disappear once we create a new event. what could be the issue?

    1. Dmitry,

      do you create one event, then another without reloading page?

  • anjali,

    I am getting the following error

    java.lang.Exception: DHXScheduler trial is out-of-time.
    at com.dhtmlx.planner.DHXPlanner.check_trial(Unknown Source)
    at com.dhtmlx.planner.DHXPlanner.render(Unknown Source)
    at jsp_servlet.__javaplanner.getPlanner(
    at jsp_servlet.__javaplanner._jspService(
    at weblogic.servlet.jsp.JspBase.service(

  • Leon,

    I run downloaded JavaPlanner.war under Tomcat 7.0.32 and obtain next error:

    org.apache.jasper.JasperException: An exception occurred processing JSP page /javaplanner.jsp at line 12

    9: s.setInitialDate(2013, 0, 23);
    10: s.load(“events.jsp”, DHXDataFormat.JSON);
    12: return s.render();
    13: }
    14: %>

  • Juan,

    Hi.. I followed the tutorial and now I’m seeing events from my database. However, if I edit or create new events, they aren’t getting persisted. What could be the problem?


    1. administrator,

      Hi, have you completed the second part of the tutorial stating from the step 4th Setting Up the Database (MySQL)? If the problem persists, send us a link to your project.

  • walid,

    where i most put the file of codesource

  • Dipti,

    Is this Javaplanner compatible with Struts version 1.3?

  • kr.vart,

    hello. Please anybody help me with javaplanner code.

    getting error on line
    public Integer saveEvent(DHXEv event, DHXStatus status) {….

    it is showing
    The return type is incompatible with DHXEventsManager.saveEvent(DHXEv,
    what is this? I just copied it. else everything is fine here.

  • s,

    C:\is202\JavaPlanner\src\java\com\dhtmlx\demo\ error: saveEvent(DHXEv,DHXStatus) in EventsManager cannot override saveEvent(DHXEv,DHXStatus) in DHXEventsManager
    public Integer saveEvent(DHXEv event, DHXStatus status) {
    return type Integer is not compatible with DHXStatus
    C:\is202\JavaPlanner\src\java\com\dhtmlx\demo\ error: method does not override or implement a method from a supertype

    getting these errors,

  • walid,

    The class won’t compile because the Integer return type for saveEvent() is incompatible with the superclass DHXEventsManager.saveEvent which is expecting DHXStatus.

    You should return status instead since JavaPlanner v1.5:

    public DHXStatus saveEvent(DHXEv event, DHXStatus status) {

    return status;

  • maksim,

    on this line of code in EventManager.jva with MySql
    public Integer saveEvent(DHXEv event, DHXStatus status) {

    Eclipse want to change Integer and said:

    Multiple markers at this line
    - The return type is incompatible with DHXEventsManager.saveEvent(DHXEv,
    - The return type is incompatible with DHXEventsManager.saveEvent(DHXEv,
    - overrides com.dhtmlx.planner.DHXEventsManager.saveEvent
    - Method breakpoint:EventsManager [entry] – saveEvent(DHXEv, DHXStatus)

  • Yogendra,

    I am not able to run project on server. getting error in console logs:

    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.FutureTask$Sync.innerGet(
    at java.util.concurrent.FutureTask.get(
    at org.apache.catalina.core.ContainerBase.startInternal(
    at org

    - Deleted and added server once again.
    - Changed the port number.
    - This mainly happens when project configured to server.

  • Biston,

    Hi I copied your project and get an error on:

    public Integer saveEvent(DHXEv event, DHXStatus status){

    return event.getid();
    the error is:
    The return type is incompatible with DHXEventsManager.saveEvent(DHXEv, DHXStatus)


  • administrator,

    Hi everyone!
    We’ve updated the tutorial according to the updates in javaplanner v.1.5.
    Sorry for the inconvenience.

  • Pallavi,

    Hi Admin,

    I have followed all the steps as specified in this blog. But am using oracle as database connection to this link and trying to execute the code you have specified and steps to…. am facing problem at date format though i have used timestamp and set date format accordingly. Could you please suggest me what format i have to use when using Oracle as backend to store values.

    1. Dmitry,

      please, try to set Date object without formatting:
      ps.setString(2, event.getStart_date());
      ps.setString(3, event.getEnd_date());

  • Miloš Drinčević,

    Working fine, thank You

  • Abdul,

    Does this only work for web applications or can I implement it into a jpane in java?

    1. Dmitry,

      Hi, it works only for web apps.

  • Pat,

    Hi, is it possible to limit one event per day? would be perfect for our university project than.

    thanks in advance

  • mars,

    thank you sooo much.. that is what i exactly wanted.

  • mars,

    please tell me where to alter the code so as to place the calendar in the middle(or customize its position according to the need) of the page.
    project works smoothly.. thanks again.

    1. Dmitry,

      you should customize file javaplanner.jsp and place element with id=”planner” in the center using css or javascript. JavaPlanner doesn’t provide such ability.

      1. mars,

        thank you so much

  • Amao,

    Is it possible to assign only one event at any time span?It’s like one resource can only be used at one user at a time.

    1. Dmitry,

      you should enable extension COLLISION:

      It denies events at the same time.

  • Raghu,

    There is a difference in the video tutorial and the text version. Here , in the text version, the user is asked to add the In the video version, its not mentioned. Where can we find that Jar? The app is not working for me when I am doing everything except adding the

    1. Dmitry,

      it’s a mistake, you should add javaplanner.jar into build path instead. The article text is updated. Sorry for the inconvenience.

  • Rafael,

    Hi to all,

    I need to display a scheduler, I’ve read and developed the examples shown in the page, however I have this error:

    [mvc-dispatcher]] (http-localhost- Servlet.service() para servlet mvc-dispatcher lanzó excepción: java.lang.NullPointerException
    at com.dhtmlx.planner.DHXEventsManager.load( [javaplanner-1.5.jar:]
    at [javaplanner-1.5.jar:]

    I use JBoss 7.1, Spring 3.2.8 and this is part of my code in my controller class

    public ModelAndView planner(HttpServletRequest request) throws Exception {
    DHXPlanner p = new DHXPlanner(“./codebase/”, DHXSkin.TERRACE);
    p.setInitialDate(2013, 1, 7);
    p.load(“events”, DHXDataFormat.JSON);

    ModelAndView mnv = new ModelAndView(“article”);
    mnv.addObject(“body”, p.render());
    return mnv;

    @ResponseBody public String events(HttpServletRequest request) {

    CustomEventsManager evs = new CustomEventsManager(request);

    I hope someone can help to solve this. Thanks.


    1. Dmitry,

      sorry for the delay in answerring.
      It looks like you missed something in step 2.6.
      Method CustomEventsManager.getEvents returns null instead of list of events for some reasons .
      Please, make sure that signature of method getEvents is the same as here:

      public Iterable getEvents()

  • RD,

    public Integer saveEvent(DHXEv event, DHXStatus status) {
    return event.getId();

    I keep getting this error. “The return type is incompatible with DHXEventsManager.saveEvent(DHXEv, DHXStatus)

    I’ll appreciate it, if anyone could help.

    1. Dmitry,

      Please, update your code of according the follow:

      public DHXStatus saveEvent(DHXEv event, DHXStatus status) {
      return status;

  • frank,

    I’ve copied this tutorial word for word and followed the video tutorial. MY database is connecting to the app and so’s the data (through debugging) but my table data isn’t being displayed on my calendar.

    1. frank,

      resolved.. sorry, my events.jsp page had other HTML tags in it and was breaking things. Everything is in order now. However i would love to get my hands on the javadoc documentation for intellisense of my eclipse. Can you guys help me out with that?

      1. Dmitry,

        unfotunately we don’t provide javadoc documentation for intellisense.


    Dear Admin,
    I have followed the mentioned steps. I am using NetBeans IDE. However when i run the application, it shows me blank JSP. I checked in all browsers. In Firefox even i checked using Inspect Element. It is not showing any error.

    Could you please tell me the possible cause for this ?


    1. Andres,

      Hi Admin,
      I am having the same issue as Kailash; I browse to http://localhost:8080/JavaPlanner/javaplanner.jsp and am getting a blank page. If I view source I see some HTML but it looks like the references to ./codebasedhtmlxscheduler.js and ./codebase/dhtmlxscheduler.css are broken.

      1. Andres,

        Found a work around –
        I downloaded

        I grabbed the 2 missing files and dropped them in to the WebContent folder in the eclipse project.

        I updated javaplanner.jsp and changed the line:
        DHXPlanner s = new DHXPlanner(“./codebase/”, DHXSkin.TERRACE);

        DHXPlanner s = new DHXPlanner(“”, DHXSkin.TERRACE);

        There may be a better solution but I am in a hurry here trying to evaluate some options for our product.
        Just thought I’d share my solution in case some one else runs in to the same issue.

  • Dmitry,

    Hi guys.
    It looks like javascript/css files are missed on your web-server. Please, make sure that you made step 2.1 correctly. Please, try to update your project to make your IDE “see” this directory:

    2.1. Open your project folder on the disc, and copy javaplanner-v1.0.jar into WebContent/WEB-INF/lib/. The folder codebase should be copied to the WebContent folder of your project.

  • Hemant Nagpal,

    Can you please email me the source code of JavaPlanner!

  • arvind,

    i am not able to shaw the event in calendar which i set in getEvents() method EventsManager class.plz help.

    DHXEvent ev1 = new DHXEvent();
    ev1.setStart_date(“11/09/2014 05:00″);
    ev1.setEnd_date(“11/09/2013 09:00″);
    ev1.setText(“Demo event #1″);
    return events;

  • RAHUL,

    Hi ,
    i want to set time that should be start 7 AM to 9 PM . As you set date setInitialDate(2014,0, 27).


  • savindu,

    Hi admin.. i followed the tutorial and and now i can load events from the database. but each time when i am creating a new event or updating an existing one it gives me this

    could you please tell me why ??


Leave a Reply

Your email address will not be published. Required fields are marked *

× five = 40

You may use these HTML tags and attributes:
<b></b> <i></i> <strike></strike> <a href=""></a>