Coherence Hello World

Coherence Hello World

To introduce fundamental concept of oracle coherence application, we will be building simple coherence hello world standalone java application. After running this example you will understand basics of oracle coherence and could move towards integrating in your own application. Please follow steps below:

  • Install oracle coherence using this tutorial
  • Create maven project name: CoherenceJavaApplication below is final structure of the project:

Coherence Hello World

  • pom.xml:

  • Define your cache: Caches should be defined in cache deployment descriptor it should be refer by the name of your application. This makes easy for configuration changes without changing any application code. We will create distributed cache name javahonk-hello-world. To define distributed cache create XML file name: example-config.xml inside src/main/resources directory and copy paste below code:

  • Define and configure cluster: Create XML file name tangosol-coherence-override.xml inside src/main/resources directory and copy paste below code:

Note: You can choose any cluster name as you like and address should be chosen between multicast address which ranges from the through You could choose any unique number as your port. Save this file on same location where example-config.xml was saved.

  • Now start cache server instance using DefaultCacheServer class also include location of the coherence.jar file as below:

Real command: If you followed tutorial above to install oracle coherence on your local computer then command will be as below:

Coherence Hello World

  • Started server screen shot:

Coherence Hello World

  • Create standalone java program inside com.javahonk package, get cache from CacheFactory, add key value to the cache, retrieve and print its value on the console.

  • To  run oracle coherence application right click –> Run As –> Java Application you will see below Java Honk Hello World! output:

Coherence Hello World

  • That’s it. For more information on Oracle coherence please visit its official site here

download  Download sample project:  CoherenceJavaApplication

3 thoughts on “Coherence Hello World

  1. Hi Java Honk,
    Do you have any advise on making the file read the tangosol-coherence-override.xml, I have followed your example to the teeth but I keep getting this error:
    Error: Could not find or load main class

    • you will have to start cache server instance using DefaultCacheServer class also include location of the coherence.jar. Please go through installation and test tutorial by using search in JavaHonk.

  2. Hello Java Honk
    I am developing a EJB using maven, my question is where should I put both xml files when I build (mvn clean install) my project?

    thank you!

Leave a Reply

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

I am not Robot *