Skip Headers
Oracle® Coherence Tutorial for Oracle Coherence
Release 3.7.1

E22622-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

2 Installing and Configuring Eclipse and OEPE with Coherence

This chapter describes how to set up the Helios release of the Eclipse IDE for Java EE Developers (Eclipse) and Oracle Enterprise Pack for Eclipse (OEPE) 11gR1 (11.1.1.7) to build and run Coherence-based Java applications.

This chapter contains the following sections:

2.1 Installing Eclipse and OEPE

You can download an "all-in-one" version of OEPE 11gR1 (11.1.1.7) that bundles a preconfigured version of Eclipse Helios and the OEPE plug-ins. Oracle recommends installing the "all-in-one" version.

As an alternative, you can download the OEPE distribution by itself and install it into an existing Eclipse Helios installation. The OEPE installer includes Oracle WebLogic Server, Oracle Coherence, and the Oracle ADF Runtime.

To download either version, select the Downloads tab on the Oracle Enterprise Pack for Eclipse page:

http://www.oracle.com/technetwork/developer-tools/eclipse/overview/index.html

Follow the instructions in the installer. You can also find installation instructions at this URL:

http://download.oracle.com/docs/cd/E15315_07/help/oracle.eclipse.tools.common.doc/html/install.html

This tutorial assumes that you will be installing Eclipse into an eclipse folder that you have created at the file system root, for example:

C:\eclipse\*

2.2 Configuring Eclipse and OEPE for Coherence

To start and configure Eclipse for use with Coherence:

  1. Open a terminal window and verify that the PATH environment variable is set to include the Java JDK, for example: \oracle\product\jdk160_14_R27.6.5-32\bin. Note that you must have a working installation of Java SE (JDK) version 1.6 or higher.

    If the PATH environment variable does not include the Java JDK \bin folder, then set the variable as follows:

    1. Set the JAVA_HOME environment variable to the base of the JDK installation, for example:

      set JAVA_HOME=\oracle\product\jdk160_14_R27.6.5-32
      
    2. Include %JAVA_HOME%\bin in the PATH environment variable, for example:

      set PATH=%JAVA_HOME%\bin;%PATH%
      
  2. Start Eclipse.

    The eclipse executable is eclipse.exe. If you extracted Eclipse into a directory called eclipse, you will find eclipse.exe here:

    C:\eclipse\eclipse.exe 
    
  3. If Eclipse prompts you to set or select a workspace in the Workspace Launcher dialog box, enter C:\home\oracle\workspace.

    Figure 2-1 illustrates the Workspace Launcher dialog box with the path C:\home\oracle\workspace selected.

    Figure 2-1 Workspace Launcher Dialog Box

    the Eclipse Workspace Launcher Dialog Box..
    Description of "Figure 2-1 Workspace Launcher Dialog Box"

  4. After Eclipse starts, select the Java EE perspective in the menu bar.

    Figure 2-2 illustrates the location of the Java EE perspective button.

    Figure 2-2 The Java EE Perspective in the Menu Bar

    The Java EE Perspective button..
    Description of "Figure 2-2 The Java EE Perspective in the Menu Bar"

2.3 Creating a New Project in the Eclipse IDE

To create a new project in the Eclipse IDE:

  1. Select File then New then Application Client Project.

  2. In the New Application Client Project dialog box, enter a value, Coherence for example, as the Project name.

    Figure 2-3 New Application Client Project Dialog Box

    The New Application Client dialog box.
    Description of "Figure 2-3 New Application Client Project Dialog Box"

  3. In the Configuration section, click Modify. In the Project Facets dialog box, select the Oracle Coherence check box. Select version 3.7 from the drop-down list if it is not already displayed.

    Adding the Oracle Coherence facet automatically adds the coherence.jar to your project class path. It also makes these commonly used configuration files available in the Project Explorer:

    • coherence-cache-config.xml, the default cache configuration file.

    • pof-config.xml, the configuration file for Portable Object Format serialization.

    • tangosol-coherence-override.xml, the override file for operational and runtime settings used by Oracle Coherence.

    Figure 2-4 Selecting Oracle Coherence in the Project Facets Dialog Box

    Selecting Oracle Coherence in the Project Facets Dialog Box
    Description of "Figure 2-4 Selecting Oracle Coherence in the Project Facets Dialog Box"

  4. Click Save As to enter a name for the configuration in the Save Preset dialog box. For example, enter CoherenceConfig in the Name field and Includes Coherence Facet in the Description field.

    Figure 2-5 illustrates the Save Preset dialog box.

    Figure 2-5 Specifying a Configuration Name in the Save Preset Dialog Box

    The Save Preset Dialog Box
    Description of "Figure 2-5 Specifying a Configuration Name in the Save Preset Dialog Box "

    Click OK to close the Save Preset dialog box. Click OK to close the Project Facets dialog box.

  5. Click Next in the Application Client Module page of the New Application Client Project dialog box.

  6. Click Next in the Java page of the New Application Client Project dialog box to accept the defaults.

  7. Deselect the Create a default Main class in the Application Client Module page of the New Application Client Project dialog box. Click Next.

  8. In the Coherence page, illustrated in Figure 2-6, add the Coherence 3.7 library as a User Library to the project.

    Figure 2-6 Creating a Coherence User Library

    Defining the Coherence user library.
    Description of "Figure 2-6 Creating a Coherence User Library"

    1. Click the Manage Library icon, then click New in the Preferences dialog box.

    2. Enter Coherence37 in the New User Library dialog box, as illustrated in Figure 2-7. Select the System library (added to the boot class path) check box.

      Figure 2-7 Naming the Coherence Library

      Naming the Coherence library.
      Description of "Figure 2-7 Naming the Coherence Library"

    3. Click OK to close the New User Library dialog box.

    4. In the Preferences dialog box, click Add JARs to add the coherence.jar file to the library. Navigate to the location of the coherence.jar file in the Coherence distribution that you downloaded to your file system in "Installing Coherence".

      Figure 2-8 illustrates the JAR Selection dialog box with the coherence.jar file selected.

      Figure 2-8 Adding coherence.jar File to the Coherence User Library

      the JAR Selection dialog box with coherence.jar
      Description of "Figure 2-8 Adding coherence.jar File to the Coherence User Library"

    5. the Preferences dialog box should look similar to Figure 2-9. Click OK to close the Preferences dialog box.

      Figure 2-9 The coherence.jar File Defined in the Coherence User Library

      coherence.jar File Defined in the Coherence User Library
      Description of "Figure 2-9 The coherence.jar File Defined in the Coherence User Library"

  9. Select the Coherence37 library in the Coherence page and click Finish.

The new project and its associated files appear in the Project Explorer window in the Eclipse IDE.

2.4 Launching a Cache Server in the Eclipse IDE

  1. Right click the project in the Eclipse IDE. Select Run As then Run Configurations. In the Run Configurations dialog box, select Oracle Coherence then the New launch configuration icon. Enter DefaultCacheServer as the name for the cache server configuration.

  2. Under Project, click Browse and select the name of the project from the Project Selection dialog box.

  3. Under Main class, select the Include system libraries when searching for a main class checkbox. Click the Search button and enter DefaultCacheServer in the Select Main Type dialog box. Select com.tangosol.net.DefaultCacheServer and click OK. Click Apply. The Main tab should look similar to Figure 2-10.

    Figure 2-10 Main Tab in the Run Configurations Dialog Box

    Main tab in the Run Configurations Dialog Box
    Description of "Figure 2-10 Main Tab in the Run Configurations Dialog Box"

  4. In the Coherence tab, select the General tab. Click the Browse icon to navigate to the cache configuration file. Select local storage to be enabled (cache server). Enter a unique value, such as 3155 for the Cluster port. Click Apply. The Coherence tab should look similar to Figure 2-11.

    Figure 2-11 Coherence Tab of the Run Configurations Dialog Box

    Coherence Tab of the Run Configurations Dialog Box
    Description of "Figure 2-11 Coherence Tab of the Run Configurations Dialog Box"

  5. Open the Arguments tab. Enter -showversion in the VM Arguments field. Click Apply.

  6. Open the Common tab of the dialog box. Click the Shared file radio button and click Browse to navigate to the project. Click Apply. The Common tab should look similar to Figure 2-12.

    Figure 2-12 Common Tab of the Run Configurations Dialog Box

    Common Tab of the Run Configurations Dialog Box
    Description of "Figure 2-12 Common Tab of the Run Configurations Dialog Box"

  7. Click Run to start the cache server. The cache server should start and display output similar to Example 2-1.

    Example 2-1 Cache Server Output in the Eclipse Console Window

    java version "1.6.0_14"
    Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
    Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode)
    2011-03-14 17:08:24.053/0.281 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"
    2011-03-14 17:08:24.116/0.344 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
    2011-03-14 17:08:24.147/0.375 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/home/oracle/workspace/InsertValue/build/classes/tangosol-coherence-override.xml"
    2011-03-14 17:08:24.147/0.375 Oracle Coherence 3.7.0.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
     
    Oracle Coherence Version 3.7.0.0 Build 22913
     Grid Edition: Development mode
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     
    2011-03-14 17:08:24.397/0.625 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/coherence-cache-config.xml"
    2011-03-14 17:08:24.600/0.828 Oracle Coherence GE 3.7.0.0 <D4> (thread=main, member=n/a): TCMP bound to /130.35.99.213:8088 using SystemSocketProvider
    2011-03-14 17:08:28.116/4.344 Oracle Coherence GE 3.7.0.0 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x96AB" with Member(Id=1, Timestamp=2011-03-14 17:08:24.6, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:2412, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) UID=0x822363D50000012EB6D79318C2D51F98
    2011-03-14 17:08:28.116/4.344 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0x96AB
     
    Group{Address=224.3.7.0, Port=3155, TTL=4}
     
    MasterMemberSet
      (
      ThisMember=Member(Id=1, Timestamp=2011-03-14 17:08:24.6, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:2412, Role=CoherenceServer)
      OldestMember=Member(Id=1, Timestamp=2011-03-14 17:08:24.6, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:2412, Role=CoherenceServer)
      ActualMemberSet=MemberSet(Size=1, BitSetCount=2
        Member(Id=1, Timestamp=2011-03-14 17:08:24.6, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:2412, Role=CoherenceServer)
        )
      RecycleMillis=1200000
      RecycleSet=MemberSet(Size=0, BitSetCount=0
        )
      )
     
    TcpRing{Connections=[]}
    IpMonitor{AddressListSize=0}
     
    2011-03-14 17:08:28.163/4.391 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2011-03-14 17:08:28.319/4.547 Oracle Coherence GE 3.7.0.0 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
    2011-03-14 17:08:28.350/4.578 Oracle Coherence GE 3.7.0.0 <D5> (thread=ReplicatedCache, member=1): Service ReplicatedCache joined the cluster with senior service member 1
    2011-03-14 17:08:28.413/4.641 Oracle Coherence GE 3.7.0.0 <D5> (thread=OptimisticCache, member=1): Service OptimisticCache joined the cluster with senior service member 1
    2011-03-14 17:08:28.413/4.641 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:InvocationService, member=1): Service InvocationService joined the cluster with senior service member 1
    2011-03-14 17:08:28.413/4.641 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=1): 
    Services
      (
      ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.7, OldestMemberId=1}
      InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
      PartitionedCache{Name=DistributedCache, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
      ReplicatedCache{Name=ReplicatedCache, State=(SERVICE_STARTED), Id=3, Version=3.0, OldestMemberId=1}
      Optimistic{Name=OptimisticCache, State=(SERVICE_STARTED), Id=4, Version=3.0, OldestMemberId=1}
      InvocationService{Name=InvocationService, State=(SERVICE_STARTED), Id=5, Version=3.1, OldestMemberId=1}
      )
     
    Started DefaultCacheServer...
    

2.5 Learning Eclipse IDE Basics

This section describes common tasks that are a part of building projects in the Eclipse IDE.

2.5.1 Creating a Java Class

To create a new Java class in the Eclipse IDE:

  1. Right-click the project entry in the Project Explorer window. Select New then Class.

  2. In the New Java Class dialog box, enter a package name. In this tutorial, the value will typically be com.oracle.handson.

  3. Enter the name of the class in the Name field.

  4. Under Which method stubs would you like to create?:

    • Select the public static void main(String[]args) if you want the file to be runnable.

    • Select Constructors from superclass check box if you want stubs of the constructors from the new class's superclass to be added.

    • Inherited abstract methods should be selected by default. This option adds stubs of any abstract methods from superclasses or methods of interfaces that need to be implemented.

  5. Click OK to create the Java class.

Figure 2-13 illustrates the New Java Class dialog box.

Figure 2-13 Defining a New Java Class

Defining a New Java Class
Description of "Figure 2-13 Defining a New Java Class"

2.5.2 Creating a Runtime Configuration

To create a runtime configuration for a runnable file:

  1. Right click the name of the runnable file in the Project Explorer window. Select Run As then Run Configurations.

  2. Click Oracle Coherence, then the New Launch Configuration icon. Select the Java Application node. Click the New Launch Configuration button.

  3. Enter a name for the new configuration. Under Project in the Main tab, click the Browse button to navigate to the name of the current project. Click the Search button to navigate to the name of the runnable file for which you are creating the runtime configuration. Click Apply.

    This figure illustrates the Main tab of the Run Configurations dialog box.

    Figure 2-14 Defining a Launch Configuration for a Runnable File

    Defining a Lauch Configuration for a Runnable File
    Description of "Figure 2-14 Defining a Launch Configuration for a Runnable File"

  4. Click the Coherence tab. Under the General tab, you can set many of the more commonly used VM runtime arguments for the configuration. Examples of runtime arguments include the path to the cache configuration descriptor, and the local storage, log level, and cluster port values.

    Figure 2-15 illustrates the General tab of the Coherence tab in the Run Configurations dialog box.

    Figure 2-15 Setting Runtime Arguments for the Launch Configuration

    Setting Runtime Arguments for the Launch Configuration
    Description of "Figure 2-15 Setting Runtime Arguments for the Launch Configuration"

2.5.3 Stopping Cache Servers

In the Eclipse IDE, you can stop any running cache server or client by clicking the Terminate and Remove all terminated launches icons in the Eclipse Console.

However, if you look in the Windows Task Manager window, you might notice that the Java process (java.exe) associated with the server or client is still running. To prevent any errors being thrown when the server or client is restarted, you must delete its associated Java process. Select the Java process in the Windows Task Manager window and click End Process.

Figure 2-16 illustrates the Windows Task Manager window with the Java process selected.

Figure 2-16 Java Process in the Windows Task Manager

Java Process in the Windows Task Manager
Description of "Figure 2-16 Java Process in the Windows Task Manager"