Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:49:45+00:00 2026-06-07T11:49:45+00:00

I am trying to run my first Java program, an example script that interacts

  • 0

I am trying to run my first Java program, an example script that interacts with a online API (source on Github).

As it has dependencies, I follow the recommended steps using mvn test and mvn package, which seem to work (see output).

I however do not understand how to run the program that I just compiled (or packaged?). The .java file contains public final class NesstarStudyLister, so based on the pom.xml file I try (in the base directory) the following command:

mhermans@fyr:~/tmp/nesstar-api-demo$ java -cp target/nesstar_study_lister-1.0-SNAPSHOT.jar com.nesstar.demo.NesstarStudyLister

Which results in a NoClassDefFoundError.

How can I successfully run the small Java-program?

EDIT:

Based on the recommendation of Dave Newton, I used the Exec Maven plugin, which apparently simply consists of running

mvn exec:java -Dexec.mainClass=com.nesstar.demo.NesstarStudyLister

in the base directory, which flawlessly executes the java program.

The solution by Andriy Plokhotnyuk also works, using these commands:

(edit pom.xml to include the <build>...</build> information)
mvn package
java -jar target/nesstar_study_lister-1.0-SNAPSHOT-jar-with-dependencies.jar
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:49:48+00:00Added an answer on June 7, 2026 at 11:49 am

    The easiest way is generally the Exec Maven Plugin.

    Nutshell:

    • Add the exec plugin as a dependency.
    • Define the main class attribute (your program’s entry point).
    • Run the exec goal.

    You may also use Maven to create a directory with your project’s dependencies (jars) and set the classpath manually, but IMO that’s kind of a pain when you can use the plugin.

    You may also create a jar that includes all your project’s dependencies in a single file, but this may require a bit more work to explicitly include/exclude any conflicting dependencies. (With the caveat that this may be an issue with either other method as well.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First steps in FreeBSD: trying to run my installation script. Fast help needed: #
I'm trying to run my first example with spring. So I downloaded SpringSource Tool
I am trying to run a test program that allows a user to click
I am writing a script that calls another java program, to perform some tasks.
Im trying to troubleshoot my first iphone app and Ive run into a propblem
Im trying to develop my first ASP.NET MVC web app and have run into
I am trying White for the first time. I tried to run a sample
I am trying run a program from a qmake .pro file which modifies the
Situation: I'm trying run an https store (xcart) under one domain secure.example.com and I
Trying to run my program in FreeBSD OS, I have the following results: $

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.