> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Publish Java SDKs manually

This guide covers publishing Java SDKs manually. For information on automating Java SDK publishing, see [Publish Java SDKs automatically](/docs/sdk-generator/publish/java-auto/).

To share your generated Java SDK with the community, you can publish it to Maven Central. This enables other developers to easily add it as a dependency in their Maven or Gradle projects. Follow the steps below to publish your SDK to Maven Central.

## Prerequisites

To publish your SDK to Maven Central, you need the following:

* Sonatype Central Portal account ([central.sonatype.com](https://central.sonatype.com)).
* GPG key for signing artifacts.
* Namespace (group ID) verified on the Central Portal.

## Initial setup

To set up your environment for publishing to Maven Central, do the following:

1. Create account and verify your namespace:

   * Register at [central.sonatype.com](https://central.sonatype.com).
   * Verify your namespace (group ID, for example, `com.example`) through DNS or GitHub verification.
   * Verification is typically automated and completes within minutes.

2. Generate a GPG key.

   ```bash
   gpg --gen-key
   gpg --list-keys
   gpg --keyserver keys.openpgp.org --send-keys YOUR_KEY_ID
   ```

3. Configure Maven `settings.xml`. Add the following to `~/.m2/settings.xml`:

   ```xml
   <settings>
   <servers>
       <server>
       <id>central</id>
       <username>your-central-portal-token-username</username>
       <password>your-central-portal-token-password</password>
       </server>
   </servers>
   <profiles>
       <profile>
       <id>central</id>
       <activation>
           <activeByDefault>true</activeByDefault>
       </activation>
       <properties>
           <gpg.executable>gpg</gpg.executable>
           <gpg.passphrase>your-gpg-passphrase</gpg.passphrase>
       </properties>
       </profile>
   </profiles>
   </settings>
   ```

## Configure pom.xml

Add the following to your SDK's `pom.xml`:

```xml
<project>
  <!-- Basic information -->
  <groupId>com.example</groupId>
  <artifactId>your-sdk</artifactId>
  <version>1.0.0</version>
  <packaging>jar</packaging>

  <name>Your SDK</name>
  <description>SDK for Your API</description>
  <url>https://github.com/your-org/your-sdk</url>

  <!-- License -->
  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/MIT</url>
    </license>
  </licenses>

  <!-- Developers -->
  <developers>
    <developer>
      <name>Your Name</name>
      <email>your@email.com</email>
      <organization>Your Organization</organization>
    </developer>
  </developers>

  <!-- SCM -->
  <scm>
    <connection>scm:git:git://github.com/your-org/your-sdk.git</connection>
    <developerConnection>scm:git:ssh://github.com/your-org/your-sdk.git</developerConnection>
    <url>https://github.com/your-org/your-sdk</url>
  </scm>

  <build>
    <plugins>
      <!-- Maven Source Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Maven Javadoc Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.6.3</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Maven GPG Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.2.7</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Central Publishing Maven Plugin -->
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.6.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
          <autoPublish>true</autoPublish>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
```

## Publish your Java SDK to Maven Central

1. Deploy to Maven Central.

   ```bash
   mvn clean deploy
   ```

   With `autoPublish` set to `true`, artifacts are automatically published after validation. If set to `false`, you can manually publish from the Central Portal UI at [central.sonatype.com](https://central.sonatype.com).

2. Verify the publication. After deployment, verify that your artifacts are available in the staging repository on the Central Portal, for example, `https://repo1.maven.org/maven2/com/example/your-sdk/`. Once verified, they're released to Maven Central within 30 minutes.

## Publish updates

To publish updates to your SDK, do the following:

```bash
# Update version in pom.xml
mvn versions:set -DnewVersion=1.0.1
mvn versions:commit

# Deploy
mvn clean deploy
```

## Best practices for publishing Java SDKs

Use the following best practices when publishing your Java SDK to Maven Central:

* Use semantic versioning.
* Sign all artifacts with GPG.
* Include source and Javadoc JARs.
* Provide comprehensive documentation.
* Tag releases in Git.
* Consider using the Maven Release Plugin for automated releases.