---
schema_version: "1"
id: a94dfb32d26aa35434df2a99498cc6b4990bfa6124b1e95c36cb3f62f8f537e9
title: Manage Apex Classes
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_manage_packages.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_manage_packages.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 44c8737edaad65c72fea92701bdd9108e0b2a9e67d5b0b26c7c6b5d5d6ec17df
description: An Apex class is a template or blueprint from which Apex objects are created. Classes consist of other classes, user-defined methods, variables, exception types, and static initialization code.
products:
  - Salesforce Platform
release: "264"
---
# Manage Apex Classes

An Apex class is a template or blueprint from which Apex objects are created. Classes consist of other classes, user-defined methods, variables, exception types, and static initialization code.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small "><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Enterprise</strong> Editions</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
      <colgroup>
        <col style="width:74%">
        <col style="width:26%">
      </colgroup>
      <thead class="slds-text-title_caps ">
        <tr class="">
          <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d7870e64">User Permissions
            Needed</th>
        </tr>
      </thead>
      <tbody>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d7870e64 ">
            <span id="code_manage_packages__class_perm_text"><a name="code_manage_packages__class_perm_text"><!-- --></a>To define, edit, delete, set security, and
              set version settings for Apex classes:</span>
          </td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d7870e64 ">
            <span id="code_manage_packages__apex_perm_value"><a name="code_manage_packages__apex_perm_value"><!-- --></a>Author Apex</span>
          </td>

        </tr>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d7870e64 ">
            <span id="code_manage_packages__class__runtest_perm_text"><a name="code_manage_packages__class__runtest_perm_text"><!-- --></a>To run Apex tests:</span>
          </td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d7870e64 ">
            <span id="code_manage_packages__apex_runtest_perm_value"><a name="code_manage_packages__apex_runtest_perm_value"><!-- --></a>View Setup and
              Configuration</span>
          </td>

        </tr>
      </tbody>
    </table>

Once successfully saved, class methods or variables can be invoked by other Apex code, or through the SOAP API (or AJAX Toolkit) for methods that have been designated with the `webService` keyword.

The Apex Classes page enables you to create and manage Apex classes. To access the Apex Classes page, from Setup, enter Apex Classes in the Quick Find box, then select **Apex Classes**. For additional development functionality, use the Developer Console.

To create an Apex class, from the Apex Classes page, click **New** and write your Apex code in the editor.

While developers can write class methods according to the syntax outlined in the [Apex Code Developer's Guide](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/), classes can also be automatically generated by consuming a WSDL document that is stored on a local hard drive or network. Creating a class by consuming a WSDL document allows developers to make callouts to the external Web service in their Apex. From the Apex Classes page, click **Generate From WSDL** to generate an Apex class from a WSDL document.

**Dynamic Apex Classes** are dynamically generated to provide greater access into existing platform features. For example, if you register an API specification with External Services, all of the dynamically generated classes are listed under the **Dynamic Apex Classes** heading on the Apex Classes page. For the original source, click **Open**. Dynamic Apex Classes don't contribute toward the [“Maximum amount of code used by all Apex code in an org”](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm#in_topic_size_gov_limits_section) limit and are exempt from code coverage requirements.

You can add, edit, or delete Apex using the Salesforce user interface only in a Developer Edition organization, a Salesforce Enterprise Edition trial organization, or sandbox organization. In a Salesforce production organization, you can change Apex only by using the Metadata API `deploy` call, the Salesforce Extensions for Visual Studio Code, or the Ant Migration Tool. The Salesforce Extensions for Visual Studio Code and Ant Migration Tool are free resources provided by Salesforce to support its users and partners, but are not considered part of our Services for purposes of the Salesforce Main Services Agreement.

Once you have created an Apex class, you can perform various actions.

- Click **Edit** next to the class name to modify its contents in a simple editor.
- Click **Del** next to the class name to delete the class from your organization.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_note.png)
    
    Note
    
    - You cannot delete a class that is specified as a controller for a Visualforce page or component.
    - A ![Managed - Released](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/extend_code/images/icoManagedRel.gif) icon indicates that an Apex class was released in a managed package. Apex classes in packages have special considerations. For more information, see the [Use Managed Packages to Develop Your AppExchange Solution](https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/managed_packaging_intro.htm).
    - A ![Managed - Installed](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/extend_code/images/icoManagedInstalled.gif) icon indicates that an Apex class is in an installed managed package. You cannot edit or delete a class in a managed package.
    - A ![Managed - Deleted](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/extend_code/images/icoManagedDeleted.png) icon indicates that an Apex class in a previously released managed package will be deleted on the next package upload. You can choose to undelete the Apex class through the package detail page.
- If an Apex class has any methods defined as a `webService`, you can click **WSDL** next to the class name to generate a WSDL document from the class contents. This document contains all of the information necessary for a client to consume Apex Web service methods. All class methods with the `webService` keyword are included in the resulting WSDL document.
- Click **Security** next to the class name to select the profiles that are allowed to execute methods in the class from top-level entry points, such as Web service methods. For classes that are installed in your organization as part of a managed package, this link only displays for those defined as `global`.
- Click **Estimate your organization's code coverage** to find out how much of the Apex code in your organization is currently covered by unit tests. This percentage is based on the latest results of tests that you’ve already executed. If you have no test results, code coverage will be 0%.
- If you have unit tests in at least one Apex class, click **Run All Tests** to run all the unit tests in your organization.
- Click **Compile all classes** to compile all the Apex classes in your organization. If you have classes that are installed from a managed package and that have test methods or are test classes, you must compile these classes first before you can view them and run their test methods from the Apex Test Execution page. Managed package classes can be compiled only through the **Compile all classes** link because they cannot be saved. Otherwise, saving Apex classes that aren't from a managed package causes them to be recompiled. This link compiles all the Apex classes in your organization, whether or not they are from a managed package.
- Click **Compile only invalid classes** to recompile only invalid Apex classes in your organization. Salesforce automatically identifies only classes that require recompilation, which reduces compilation overhead and minimizes potential runtime errors. Routinely perform this targeted recompilation to prevent runtime delays during peak traffic. If the compilation is successful, you see a confirmation message. If the compilation is unsuccessful, you see a list of problems and warnings for each affected class.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_note.png)

Note The namespace prefix is added to Apex classes and triggers, Visualforce components and pages, brand templates, folders, s-controls, static resources, web links, and custom report types if they are included in a managed package. However, if you don't have customize application permissions, the namespace prefix field is not displayed for brand templates, folders, and custom report types.

#### See Also

- [Define Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_define_package.htm&release=264.0.0&type=5 "Salesforce stores Apex classes as metadata.")
- [View Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_view_class.htm&release=264.0.0&type=5 "After you have created a class, you can view the code contained in the class, as well as the API against which the class was saved, and whether the class is valid or active.")