Not able to load the class explicitly but able to create an instance


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Not able to load the class explicitly but able to create an instance

  1. #1
    Join Date
    Oct 2007
    Posts
    1

    Not able to load the class explicitly but able to create an instance

    Hi,

    Pls look at the following code. I am able to create an instance of pa.Sample
    with pa.Sample s = new pa.Sample();
    but not able to load the class "pa.Sample.class". It throws ClassNotFoundException.

    Any clues, why is it so?

    public static void main(String args[])
    {
    Test obj = new Test();
    String classPath = System.getProperty("java.class.path");
    System.out.println(classPath);
    try{
    Class a = obj.getClass().getClassLoader().loadClass("pa.Sample.class");
    }
    catch(ClassNotFoundException ex)
    {
    ex.printStackTrace();
    }
    pa.Sample s = new pa.Sample();

    }

  2. #2
    Join Date
    Jul 2005
    Posts
    78
    Are you passing all of the correct parts to the class?

    ie class(int, string) etc....

Similar Threads

  1. Replies: 26
    Last Post: 12-01-2012, 04:12 AM
  2. JDOM Classpath Help Required
    By kpandya in forum Java
    Replies: 5
    Last Post: 01-15-2006, 07:10 PM
  3. Help with class/applet
    By none_none in forum Java
    Replies: 17
    Last Post: 04-28-2005, 03:00 PM
  4. Replies: 5
    Last Post: 10-17-2002, 01:58 PM
  5. Help needed before 25/1/01!!!!
    By Chris reid in forum Java
    Replies: 3
    Last Post: 02-11-2001, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center