This chapter describes how to set up the Indigo release of the Eclipse IDE for Java EE Developers (Eclipse) and Oracle Enterprise Pack for Eclipse 12.1.2.0.0 (OEPE) to build and run Coherence-based Java applications.
This chapter contains the following sections:
You can download an "all-in-one" version of OEPE (12.1.2.0.0) that bundles a preconfigured version of Eclipse Juno 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 Juno 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://docs.oracle.com/cd/E27086_01/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\*
To start and configure Eclipse for use with Coherence:
Open a terminal window and verify that the PATH
environment variable is set to include the Java JDK, for example: C:\oracle\Middleware\jdk170\bin
. Note that you must have a working installation of Java SE (JDK) version 1.7 or higher.
If the PATH
environment variable does not include the Java JDK \bin
folder, then set the variable as follows:
Set the JAVA_HOME
environment variable to the base of the JDK installation, for example:
set JAVA_HOME=\oracle\Middleware\jdk170
Include %JAVA_HOME%\bin
in the PATH
environment variable, for example:
set PATH=%JAVA_HOME%\bin;%PATH%
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
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.
After Eclipse starts, select the Java EE perspective:
Select Window then Open Perspective, then Java EE, or
Select the Java EE perspective icon in the menu bar
Figure 2-2 illustrates the location of the Java EE perspective icon.
Figure 2-2 The Java EE Perspective in the Menu Bar
To create a new project in the Eclipse IDE:
Select File then New then Application Client Project.
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
In the Configuration section, click Modify. In the Project Facets dialog box, select the Oracle Coherence check box. Select version 12.1.2 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 Coherence.
Note:
The following illustration has NOT been updated for the current 12.1.2 beta release.
Figure 2-4 Selecting Oracle Coherence in the Project Facets Dialog Box
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
Click OK to close the Save Preset dialog box. Click OK to close the Project Facets dialog box.
Click Next in the Java page of the New Application Client Project dialog box to accept the defaults.
Click Next in the Application Client Module page of the New Application Client Project dialog box.
Deselect the Create a default Main class in the Application Client Module page of the New Application Client Project dialog box. Click Next.
In the Coherence page, illustrated in Figure 2-6, add the Coherence 12.1.2 library as a User Library to the project.
Figure 2-6 Creating a Coherence User Library
Click the Manage Libraries... icon, then click New in the Preferences dialog box.
Enter Coherence12.1.2 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. Click OK to close the New User Library dialog box.
In the Preferences dialog box, click Add External 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".
The Preferences dialog box should look similar to Figure 2-8. Click OK to close the Preferences dialog box.
Figure 2-8 The coherence.jar File Defined in the Coherence User Library
Select the Coherence12.1.2 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.
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.
Under Project, click Browse and select the name of the project from the Project Selection dialog box.
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-9.
Figure 2-9 Main Tab in the Run Configurations Dialog Box
In the Coherence tab, select the General tab. Click the Browse icon to navigate to the cache configuration file if it is not already selected. 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-10.
Figure 2-10 Coherence Tab of the Run Configurations Dialog Box
Open the Arguments tab. Enter -showversion
in the VM Arguments field. Click Apply.
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-11.
Figure 2-11 Common Tab of the Run Configurations Dialog Box
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.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing) 2012-08-15 14:30:18.244/3.250 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence.xml" 2012-08-15 14:30:18.307/3.313 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml" 2012-08-15 14:30:18.338/3.344 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/home/oracle/workspace/Coherence/build/classes/tangosol-coherence-override.xml" 2012-08-15 14:30:18.354/3.360 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified 2012-08-15 14:30:18.354/3.360 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified 2012-08-15 14:30:18.354/3.360 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified Oracle Coherence Version 12.1.2.0 Build 36845 Grid Edition: Development mode Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 2012-08-15 14:30:18.885/3.891 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/coherence-cache-config.xml" 2012-08-15 14:30:19.260/4.266 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/internal-txn-cache-config.xml" 2012-08-15 14:30:20.541/5.547 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory 2012-08-15 14:30:21.307/6.313 Oracle Coherence GE 12.1.2.0 <D4> (thread=main, member=n/a): TCMP bound to /130.35.99.202:8088 using SystemDatagramSocketProvider 2012-08-15 14:30:24.760/9.766 Oracle Coherence GE 12.1.2.0 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x47DB" with Member(Id=1, Timestamp=2012-08-15 14:30:21.432, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:3956, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) 2012-08-15 14:30:24.760/9.766 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0x47DB Group{Address=224.12.1.0, Port=3155, TTL=4} MasterMemberSet( ThisMember=Member(Id=1, Timestamp=2012-08-15 14:30:21.432, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:3956, Role=CoherenceServer) OldestMember=Member(Id=1, Timestamp=2012-08-15 14:30:21.432, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:3956, Role=CoherenceServer) ActualMemberSet=MemberSet(Size=1 Member(Id=1, Timestamp=2012-08-15 14:30:21.432, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:3956, Role=CoherenceServer) ) MemberId|ServiceVersion|ServiceJoined|MemberState 1|12.1.2|2012-08-15 14:30:21.432|JOINED RecycleMillis=1200000 RecycleSet=MemberSet(Size=0 ) ) TcpRing{Connections=[]} IpMonitor{Addresses=0} 2012-08-15 14:30:24.916/9.922 Oracle Coherence GE 12.1.2.0 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1 2012-08-15 14:30:24.994/10.000 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/reports/report-group.xml" 2012-08-15 14:30:25.322/10.328 Oracle Coherence GE 12.1.2.0 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1 2012-08-15 14:30:25.401/10.407 Oracle Coherence GE 12.1.2.0 <D5> (thread=ReplicatedCache, member=1): Service ReplicatedCache joined the cluster with senior service member 1 2012-08-15 14:30:25.401/10.407 Oracle Coherence GE 12.1.2.0 <D5> (thread=OptimisticCache, member=1): Service OptimisticCache joined the cluster with senior service member 1 2012-08-15 14:30:25.401/10.407 Oracle Coherence GE 12.1.2.0 <D5> (thread=Invocation:InvocationService, member=1): Service InvocationService joined the cluster with senior service member 1 2012-08-15 14:30:25.416/10.422 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=1): Services ( ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=12.1.2, OldestMemberId=1} InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=12.1.2, 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=12.1.2, OldestMemberId=1} Optimistic{Name=OptimisticCache, State=(SERVICE_STARTED), Id=4, Version=12.1.2, OldestMemberId=1} InvocationService{Name=InvocationService, State=(SERVICE_STARTED), Id=5, Version=12.1.2, OldestMemberId=1} ) Started DefaultCacheServer...
This section describes common tasks that are a part of building projects in the Eclipse IDE.
To create a new Java class in the Eclipse IDE:
Right-click the project entry in the Project Explorer window. Select New then Class.
In the New Java Class dialog box, enter a package name. In this tutorial, the value will typically be com.oracle.handson
.
Enter the name of the class in the Name field.
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.
Click OK to create the Java class.
Figure 2-12 illustrates the New Java Class dialog box.
To create a runtime configuration for a runnable file:
Right click the name of the runnable file in the Project Explorer window. Select Run As then Run Configurations.
Click Oracle Coherence, then the New Launch Configuration icon. Select the Java Application node. Click the New Launch Configuration button.
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-13 Defining a Launch Configuration for a Runnable File
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-14 illustrates the General tab of the Coherence tab in the Run Configurations dialog box.
Figure 2-14 Setting Runtime Arguments for the Launch Configuration
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-15 illustrates the Windows Task Manager window with the Java process selected.
Figure 2-15 Java Process in the Windows Task Manager