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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:39:15+00:00 2026-06-14T07:39:15+00:00

I am using reflection to get all methods from a specific class. This class

  • 0

I am using reflection to get all methods from a specific class.

This class has references to class that not in my class path so I get an exception:

java.lang.NoClassDefFoundError:

On this:

Method methods[] = theClass.getDeclaredMethods();

Is it possible, somehow,to “skip” everything that is not in classpath?

  • 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-14T07:39:17+00:00Added an answer on June 14, 2026 at 7:39 am

    Class.forName() will not load a class, whether it is or isn’t in the classpath. It will only return a handle to a class that is already loaded.

    A class gets loaded in one of 2 main ways:

    1.)The class is referenced in the import statements(java.lang.* is imported automatically so every class in java.lang package is class-loaded from the start)

    2.)A class is loaded using a call from a ClassLoader, in which case all of its dependencies are resolved. and loaded as well

    So if you are trying to load a class outside of the classpath, or with dependencies outside the classpath, you need to subclass ClassLoader and tell it how to load your classes and their dependencies.

    See ClassLoader specification here: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/ClassLoader.html

    Also, there are ready made subclasses of ClassLoader that may do what you want such as URL ClassLoader which will let you simply point the ClassLoader instance at the path, and load any classes in that path.

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

Sidebar

Related Questions

How can I get all the public methods of class using reflection when class
I am using reflection to get the DeclaredFields of a particular class. Is there
I'm currently using reflection to get the declared Fields of a GUI class. However
Using reflection on Java classes to access all field, methods, and so on: Is
When using reflection it is possible to obtain the call stack (apart from that
I am using reflection class to invoke some methods which are on the some
How to get list of all methods from WCF silverlight enabled service from code.
I have task to get static method using reflection like this : myType.GetMethod(MyMethod,BindingFlags.Static |
Suppose I get data from a service (that I can't control) as: public class
I want to use this code to grab all methods from the assembly Mscorlib.dll

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.