How to build an application in Eclipse using visual beans


In this topic


Creating a project

  1. Click File, New, and Project. See the following screen shot:
  1. Click Java Project in the Wizards list.
  2. Click Next. See the following screen shot:
  1. Type ArcGIS_Engine in the Project name field. Leave the other options set with the default values. Click Finish. See the following screen shot:
  • When you click Finish in the preceding screen shot, the ArcGIS_Engine project appears in the Package Explorer. See the following screen shot:

Creating an ArcGIS Engine library 

Before building the application, set up the libraries the application will use. Create a new library containing the ArcGIS Engine Java Archive (JAR) files needed to get started.   
  1. In the Package Explorer, right-click ArcGIS_Engine and click Properties. See the following screen shot:
  1. In the left-hand panel, click Java Build Path. In the right-hand panel, click the Libraries tab and click Add Library. See the following screen shot:
  1. Click ArcGIS Engine Library and click Next. See the following screen shot:
  1. After you click Next in the preceding screen shot, arcobjects.jar appears. Click Finish to create the library. See the following screen shot:
  1. After you click Finish in the preceding screen shot, ArcGIS Engine Library appears in the list of libraries. Click OK to add it to the project. See the following screen shot:

Building an ArcGIS Engine application

  1. Create a visual class that will be the basis for the application. Right-click the ArcGIS_Engine project. Choose New, and Visual Class. See the following screen shot:
If you don't see Visual Class in the list, choose the Other option at the bottom, then browse to Java, Visual Class, and click Next.
  1. Set the properties of the new visual class. The source folder should be ArcGIS_Engine, however, change the name to EngineApp.
  2. In the Style scroll down list, click Frame to provide a base framework for the application.
  3. Select the public static void main(String[] args) check box to create a public static void main method.
  4. Click Finish. See the following screen shot:
You will use the default package for this simple application, but larger applications should create new packages.
The Eclipse interface is similar to the following screen shot. If this is the first time you have created a visual class, it may take a while for the Visual Editor to complete. See the following screen shot:
  1. Adjust the size of the design frame by minimizing the code display. Click the drop-down arrow to maximize the pane size. See the following screen shot:


  2. Click this-"JFrame" from the Java Beans pane to activate the JFrame. See the following screen shot:
  1. Drag the corner of the JFrame to increase the size of the display. See the following screen shot:
  1. Click the palette to the left of the design frame to open the different visual beans. Click the ArcGIS Components folder to expand its contents. See the following screen shot:
  1. Click TOCBean and click the West frame. The content pane automatically places the frame to the left side. See the following screen shot:
  1. Type TOC in the Name dialog box and click OK. See the following screen shot:

  2. Click MapBean from the palette and click the center portion of the frame. Name the frame Map and click OK.
  3. Click ToolbarBean from the palette and click the North section. Name the North section ToolBar. See the following screen shot:
  1. Building the simple application for the framework is complete. Now, the visual bean properties must be set to properly interact with each other. Click the ESRI TOCControl to make it active. In the Property list, click the BuddyControl property and click the drop-down arrow in the Value column to show a list of the applicable values. The Map value entered in Step 12 for the MapBean in the application appears. Click Map to set the property. See the following screen shot:
  1. The ToolBarBean needs the same property set. Activate the ESRI ToolBarControl and also set its BuddyControl property to Map. All the components are ready to interact with each other. The next step is to add data to the map and tools to the toolbar. 
  2. Right-click the ESRI MapControl and click Customize Java Bean. See the following screen shot:
  1. Various properties for the map can be set, but at this point choose a map document to display. Click the open folder button and browse to a *.mxd file (ArcGIS/java/samples/data/mxds/usa.mxd). Click OK to close the dialog box. See the following screen shot:
  1. Right-click the ESRI ToolBarControl and open its Customize Java Bean dialog box.
  2. Click the Items tab and click Add.
  3. Scroll to the Map Navigation category (you can select different types of commands to be included on the toolbar). See the following screen shot:
  1. In the preceding screen shot, you can double-click individual commands or a category to add them to the toolbar. You can also highlight a command and click the Add Command button to add it separately. For now, choose several items to add and click Close; all the items appear in the Java Property Editor (you can also remove added items). See the following screen shot:
  1. Right-click an item that you want to remove and click Delete. You can also begin a toolbar group or show text instead of the icon on the toolbar. Leave the Image Only option selected to show the icons. See the following screen shot:
  1. Click OK when you are finished setting up the toolbar.

Completing the code and initializing the ArcGIS Engine license

You are almost ready to run your application. However, you must set an appropriate runtime license and make a few other additions to the code. 
  1. Expand the code view to take up more of the Eclipse interface. In several places, some red underlined code is visible with a small red x on the left panel. Eclipse is showing that this item needs attention and it can be resolved by clicking the red x. See the following screen shot:
  1. Options to fix the code appear. Click Surround with try/catch to resolve the situation and to automatically insert the code. See the following screen shot:

 
Do this procedure for the TOC, toolbar, and map components where the red x appears. Alternatively, set the preferences in the visual editor to always create the try/catch block. Click Window, Preferences, and click Java/Visual Editor. Click the Code Generation tab and select the Generate try{}catch() block check box to automatically add the try/catch block each time. See the following screen shot: 
  1. The ArcGIS Engine application needs to be properly licensed. A shortcut is available to create this code. Right-click in the code editor and click ArcGIS, Insert License Code. See the following screen shot:
  1. Select the ArcGIS Engine check box and click OK. See the following screen shot: 

This code creates a new method to initialize the ArcGIS license check for the ArcGIS Engine product code. For more information regarding licensing and its uses, see Licensing and deployments
  1. After creating the license method, call it within the main method of the application before it starts. Below the line initialize(); in the default constructor, add the following code example:
[Java]
initializeArcGISLicenses();
  1. Initialize the visual beans in the main method. In the public static void main method, type the following code example: 
[Java]
com.esri.arcgis.system.EngineInitializer.initializeVisualBeans();
  1. Create a new instance of the application and make it visible before running it. Type the following code example in the main method:
[Java]
EngineApp map = new EngineApp();
map.setVisible(true);
  1. Save your project.
  2. Right-click EngineApp.java in the Package Explorer and click Run As and Java Application. See the following screen shot:
  1. The application window appears with the specified toolbar and map items. See the following screen shot:






Development licensing Deployment licensing
Engine Developer Kit Engine Runtime