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

  • Home
  • SEARCH
  • 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 7086337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:14+00:00 2026-05-28T07:32:14+00:00

I am trying to run a class, but I get the following error: java.lang.NoClassDefFoundError:

  • 0

I am trying to run a class, but I get the following error:

java.lang.NoClassDefFoundError: MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 Exception in thread "main" 

It happens, although the main method is in MyClass and I run directly this class.
Why is this class not found, although I launch the program from it?

Here is some code:

public class MyClass extends A implements B{
public MyClass() throws Exception {
//make some initializations
}
public static void main(final String[] args) throws Exception {
MyClass myClass = new MyClass();
//do stuff with myClass
}
}

PS: I am using Eclipse Indigo.

EDIT
I have run the class in the Command Line twice:

D:\Eclipse JEE\Workspace2\Example\target\classes\com\example\main>java com.example.main.MyClass
Exception in thread "main" java.lang.NoClassDefFoundError: com/example/main/MyClass
Caused by: java.lang.ClassNotFoundException: com.example.main.MyClass
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.example.main.MyClass.  Program will exit.

D:\Eclipse JEE\Workspace2\Example\target\classes\com\example\main>java GeoDAOImpl
Exception in thread "main" java.lang.NoClassDefFoundError: MyClass(wrong name: com/example/main/MyClass)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: MyClass.  Program will exit.
  • 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-28T07:32:15+00:00Added an answer on May 28, 2026 at 7:32 am

    You haven’t really given us enough information to say for sure, but my guess is that either:

    • You’re not giving the right fully-qualified class name
    • Your class isn’t on the classpath

    For an example of the first case, if your code looks like this:

    package foo;
    
    public class MyClass {
        public static void main(String[] args) {
        }
    }
    

    Then you should be running:

    java foo.MyClass
    

    EDIT: With the extra information provided, I suspect I know what’s happened. I suspect the class was created not in a package, and a Run Configuration was created which just runs MyClass. It’s now been moved into com.example.main, but without the Run Configuration being updated.

    Go into the Run Configuration editor (click on the dropdown next to the “run” button, and select Run Configurations…) and find “MyClass”, then check which class is going to be run, and edit it to put the right package name in.

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

Sidebar

Related Questions

I am trying to run jboss. But I get the following error: [javac] C:\Program
I'm trying to import and run the GreenDroid project: https://github.com/cyrilmottier/GreenDroid But get the following
I am trying to run the following C function from Java using JNA, but
I get the following error: Exception in thread main java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet; at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399) at
I am trying to run a function of the main class, but even with
I'm trying to get a class memeber variable list at run time. I know
I am trying to compile and run a simple java class within eclipse. The
I am trying to run PhotoStream sample from following link http://android-developers.blogspot.com/2008/09/android-photostream.html But when i
I'm trying to create an instance of a class at run time. The classes
Trying to run the following command in php to run powershell command... the following

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.