Writing Apex Using Development Environments

There are several development environments for developing Apex code. The Force.com Developer Console and the Force.com IDE allow you to write, test, and debug your Apex code. The code editor in the user interface enables only writing code and doesn’t support debugging. These different tools are described in the next sections.

Force.com Developer Console

The Developer Console is an integrated development environment with a collection of tools you can use to create, debug, and test applications in your Salesforce organization.

To open the Developer Console in Salesforce user interface, click Your name | Developer Console.

The Developer Console supports these tasks:
  • Writing code—You can add code using the source code editor. Also, you can browse packages in your organization.
  • Compiling code—When you save a trigger or class, the code is automatically compiled. Any compilation errors will be reported.
  • Debugging—You can view debug logs and set checkpoints that aid in debugging.
  • Testing—You can execute tests of specific test classes or all tests in your organization, and you can view test results. Also, you can inspect code coverage.
  • Checking performance—You can inspect debug logs to locate performance bottlenecks.
  • SOQL queries—You can query data in your organization and view the results using the Query Editor.
  • Color coding and autocomplete—The source code editor uses a color scheme for easier readability of code elements and provides autocompletion for class and method names.

Force.com IDE

The Force.com IDE is a plug-in for the Eclipse IDE. The Force.com IDE provides a unified interface for building and deploying Force.com applications. Designed for developers and development teams, the IDE provides tools to accelerate Force.com application development, including source code editors, test execution tools, wizards and integrated help. This tool includes basic color-coding, outline view, integrated unit testing, and auto-compilation on save with error message display. See the website for information about installation and usage.

Note
The Force.com IDE is a free resource provided by Salesforce to support its users and partners but isn't considered part of our services for purposes of the Salesforce Master Subscription Agreement.
Tip
If you want to extend the Eclipse plug-in or develop an Apex IDE of your own, the SOAP API includes methods for compiling triggers and classes, and executing test methods, while the Metadata API includes methods for deploying code to production environments. For more information, see Deploying Apex and SOAP API and SOAP Headers for Apex.

Code Editor in the Salesforce User Interface

The Salesforce user interface. All classes and triggers are compiled when they are saved, and any syntax errors are flagged. You cannot save your code until it compiles without errors. The Salesforce user interface also numbers the lines in the code, and uses color coding to distinguish different elements, such as comments, keywords, literal strings, and so on.
  • For a trigger on a standard object, from Setup, click Customize, click the name of the object, and click Triggers. In the Triggers detail page, click New, and then enter your code in the Body text box.
  • For a trigger on a custom object, from Setup, click Develop | Objects, and click the name of the object. In the Triggers related list, click New, and then enter your code in the Body text box.
  • For a class, from Setup, click Develop | Apex Classes. Click New, and then enter your code in the Body text box.
Note
You cannot make changes to Apex using the Salesforce user interface in a Salesforce production organization.

Alternatively, you can use any text editor, such as Notepad, to write Apex code. Then either copy and paste the code into your application, or use one of the API calls to deploy it.

© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.