Deploy a Java application

This blog records the steps to publish a Java application to the Central Repository.

First, what is the Central Repository?

It is a platform to publish the applications, maintained by Sonatype Inc. The Central Repository is the default repository for Apache Maven, Gradle etc. Maven Central Repository Search is the official central search engine of the Central Repository, whereas Central Repository: ( is the real repository where your component is published.

For example, you can download my application from Maven Central Repository Search directly, while you can find the source files from Central Repository: com/github/jossiey/LinkChecker-CmdLC/1.0 ( as well.

Next, this blog is focusing on the deployment of an open source individual projects. The official instructions can be found here: Individual Projects – Open Source Software Repository Hosting (OSSRH). It provides a number of short tutorials for beginners, which are helpful.

Now, let’s start to publish a Java application.

Step1: Create a ticket with Sonatype

Before you can upload your project to Nexus Repository Manager (, you need to:

  1. Create a Sonatype JIRA account
  2. Create a New Project ticket

If you choose com.github.your_github_account as your Group Id, you will receive an email asking you to create a public repo to verify github account ownership. Once you done, you are ready to next step.

Step2: Generate a PGP Signature

  1. Install GnuPG

Download GPG from or install it with your favorite package manager. Then run gpg --version to verify it works.

2. Generate a Key Pair

Run command gpg --gen-key , follow the prompt entering your name, email, and a comment for the key.

Run command gpg --list-keys to list your public keys

3. Distribute the Public Key

gpg2 --keyserver hkp:// --send-keys 435EF2D3

This command distributes your public key to a key server. Note: You don’t need to sign a file now, once you configure your pom.xml file, mvn will do the sign for you automatically.

Step3: Configure your pom.xml and settings.xml files

  1. Configure pom.xml
  • Distribution Management and Authentication
  • Project Profile
  • Nexus Staging
  • Javadoc and Source Attachments
  • GPG Signed Component

This component will sign your project_name.jar, project_name-javadoc.jac, project_name-sources.jar with your public key automatically when you run mvn deploy. You can find the signature files project_name.jar.asc, project_name-javadoc.jac.asc, project_name-sources.jar.asc in the target folder.

2. Configure settings.xml

In Eclipse IDE, open your settings.xml from Windows -> Preference -> Maven -> User Settings.

Alternatively, you can open the file from the directory.

Global Setting C:\Program Files\apache-maven-3.6.3\conf\settings.xml   [global settings]
User Setting ${user. home}/. m2/settings.xml    [user settings]

Step4: Push your project to Nexus staging repository

Run command mvn deploy in command line or right click pom.xml in Ecilpse IDE, click Run As -> mvn build...

Step5: Release the project in Nexus repository manager

Login your Nexus repository manager account, click close button, Sonatype need to check all requirements rule. Once it done with no errors, release button will be active. Click release to finish the deployment.

Some problems I encountered and how I solved:

  1. When I run mvn deploy , system prompted an 401 error.

Try to reset the user token, and update settings.xml. Run mvn clean deploy again.

2. %JAVA_HOME% is not correctly set

Try to follow this blog How to set JAVA_HOME in Windows 10 to set environment variable JAVA_HOME and run mvn clean deploy again.

3. Javadoc validation and source validation failed

Make sure the plugin of source, javadoc and gpg are called and run properly when you run the command mvn deploy

Last, I hope this blog is helpful for you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s