Results 1 to 3 of 3
  1. #1
    praveen.kb is offline Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    0

    Question Load class file which resides in local path c:\

    Hi

    I wanted to load and run class file residing under local path from my project.
    I am using Class.forName() to accomplish this. Its successfully loading if the the class resides within package.But the class file has to be kept in local drive say C:\
    I tried this way..
    Class _class2 = Class.forName("C:/HelloWorld");
    Where HelloWorld is a class residing in C:\

    How can i approach this? Is this way wrong? Do i need to use some other way? Please help.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default

    Read the API doc for the forName() method. It takes a class name, not a path.
    Look at the getResource() method
    Or perhaps you need a custom class loader

Similar Threads

  1. trying to get class name & path
    By sandor in forum New To Java
    Replies: 4
    Last Post: 08-12-2008, 01:38 PM
  2. Setting up class path for Eclipse
    By tsantana in forum Eclipse
    Replies: 1
    Last Post: 04-07-2008, 07:05 PM
  3. Log4J.jar in class path
    By eva in forum New To Java
    Replies: 0
    Last Post: 01-02-2008, 06:39 PM
  4. how to load a java class in startup
    By leonard in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 03:36 AM
  5. How to load binary content of a .class file
    By boy22 in forum Advanced Java
    Replies: 1
    Last Post: 08-03-2007, 06:21 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
  •