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 5957943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:28:22+00:00 2026-05-22T18:28:22+00:00

I have a very simple HelloWorld code in Java which works ok. I’m using

  • 0

I have a very simple HelloWorld code in Java which works ok. I’m using Eclipse and trying to figure out how to import dependencies for a project with the maven2 eclipse plugin.

    public class testMavenDep {

        public static void main(String arg[]){
            System.out.println("Hello World");
        }
    }

However, when I right click on the project > configure > convert to maven project, and then try and run it gives me an error message saying…

Could not find the main class: testMavenDep.testMavenDep. Program will exit.

And the following in the console…

java.lang.NoClassDefFoundError: testMavenDep/testMavenDep
Caused by: java.lang.ClassNotFoundException: testMavenDep.testMavenDep
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread “main”

My pom file is…

<project xmlns="http://maven.apache.org/POM/4.0.0"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-    4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>testMavenDep</groupId>
  <artifactId>testMavenDep</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</project>

My question is, for an already existing Java Project, what is the proper way to add maven dependencies? I can add the dependencies using the above method but I’m getting issues with it losing track of the main class. Thanks in advance!

  • 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-05-22T18:28:23+00:00Added an answer on May 22, 2026 at 6:28 pm

    What is the source folder that you are putting your main class in? By default, Eclipse puts it in src, but maven conventions are src/main/java. It could be that adding maven dependencies is changing your source folders so that your class is not compiled.

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

Sidebar

Related Questions

I have a very simple WPF application in which I am using data binding
I have a very simple Java RMI Server that looks like the following: import
I have a very simple problem which requires a very quick and simple solution
I have the source code for some very simple command line programs. I was
I have developed an applet java with Eclipse, which is included in MyPage.html. I
I'm trying to learn how to profile perl memory. I have a very simple
When running javap on a very simple HelloWorld application I have some confusion on
i have very simple problem. I need to create model, that represent element of
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have very simple window where I have 2 buttons - one for cancel,

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.