How do I create an object from a filename?

I'm traversing directories and storing a list of files in a File array. Then I traverse the array looking at the extension of the file. If it is .java then I would like to instantiate it as a class so that I may pass the new object to another function which will examine its methods. I've tried Class.forName(file.getCanonicalPath()) and it throws a ClassNotFound exception. How can I create an object from a valid filename, please?

Rick_Avlonitis wrote:
If it is .java then I would like to </snip>.java files contain source code, they can't be "instantiated". Class.forName() takes a classname as parameter, i.e. "mypackage.MyClass". A class name is not a file name, and it doesn't have an extension. As stated in the other reply, you'll need to have the class on your class path.

Similar Messages

  • How to create and object from an arrayList

    Hi I want to create an object from an arrayList.
    here is my code...
    BillingQueryParam billingQueryParam = new BillingQueryParam();
    /*This BillingQueryParam and billingItemManagerActionForm has getter and setter method for following attributes.
    private int billingItemId;
    private String[] paramName;
    private String[] defaultParamValue;
    List billingQueryParamList = new ArrayList();               
    for(int i = 0; i < billingItemManagerActionForm.getParamName().length; i++) {
         billingQueryParam.setParamName(billingItemManagerActionForm.getParamName());
    for(int i = 0; i < billingItemManagerActionForm.getDefaultParamValue().length; i++) {
      billingQueryParam.setDefaultParamValue(billingItemManagerActionForm.getDefaultParamValue());
         billingQueryParam.setBillingItemId(billingItem.getBillingItemId());
         billingQueryParamList.add(billingQueryParam);
    System.out.println("****** ArrayList Size-->"+billingQueryParamList.size());
    for (Iterator iter = billingQueryParamList.iterator();iter.hasNext();) {
         billingQueryParam = (BillingQueryParam)iter.next();
          System.out.println("****** BillingItemId-->"+billingQueryParam.getBillingItemId());
          System.out.println("****** Param Name-->"+billingQueryParam.getParamName()); //printing an array of paramName
          System.out.println("****** Default param value-->"+billingQueryParam.getDefaultParamValue());
    }Here after iterating this list I want to create an object of billingQueryParam which contains a single value of itemId, paramName,paramTypeId and defaultParamName and I want to persist this object in database.
    Please help...!!!
    Thanks

    Now this is too much.. Do i need to tell this thing to u as well. How did u come to this forum?
    Can't u see link to Java programming forum at the top.

  • How can you move the objects from one server to another?

    how can you move the objects from one server to another?

    Hi,
    Collecting objects for Transporting
    1. rsa1->transport connection
    2. left panel choose 'object type', middle panel choose 'infocube' and 'select objects'
    3. then choose your infocube and 'transfer'
    4. will go to right panel, choose collection mode 'manual' and grouping only 'necessary objects'
    5. after objects collection finished, create request
    6. If they are $TMP, then change the package.
    7. When you click the Save on the change package, it will prompt for transport. Here you can provide an existing open transport request number, or if you like here itself you can create a new one.
    8. You can check the request in SE09 to confirm.
    Releasing Transport Request  
    Lets say you are transporting from BWD to BWQ
    Step 1: In BWD go to TCode SE10
    Step 2: Find the request and release it (Truck Icon or option can be found by right click on request #)
    Note: First release the child request and then the parent request
    Steps below are to import transport (generally done by basis )
    Step 1: In BWQ go to Tcode STMS
    Step 2: Click on Import queue button
    Step 3: Double Click on the line which says BWQ (or the system into which transport has to be imported)
    Step 4: Click on refresh button
    Step 5: High light the trasnport request and import it (using the truck icon)
    Transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/0b/5ee7377a98c17fe10000009b38f842/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/224381ad-0701-0010-dcb5-d74236082bff
    Hope this helps.
    thanks,
    JituK

  • Dynamically create Value Objects from XML file

    Hi
    I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.

    Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.

  • Why can't I create new object from a class that is in my big class?

    I mean:
    class A
    B x = new B;
    class B
    and how can I solve it if I still want to create an object from B class.
    Thank you very much :)

    public class ItWorksNow  {
      public ItWorksNow() {
      public static void main ( String[] argv )  throws Exception {
        ItWorksNow.DaInnaClass id = new ItWorksNow().new DaInnaClass();
      public class DaInnaClass {
    }

  • How to pass arraylist of object from action class to jsp and display in jsp

    I need to do the following using struts
    I have input jsp, action class and action form associated to that. In the action class I will generate the sql based on the input from jsp page/action form, create a result set. The result set is stored as java objects in a ArrayList object.
    Now I need to pass the arraylist object to another jsp to display. Can I put the ArrayList object in the request object and pass to the success page defined for the action? If this approach is not apprpriate, please let me know correct approach.
    if this method is okay, how can I access the objects from arraylist in jsp and display their property in jsp. This java object is a java bean ( getter and setter methods on it).
    ( need jsp code)
    Can I do like this:
    <% ArrayList objList = (ArrayList)request.getattribute("lookupdata"): %> in jsp
    (***I have done request.setattribute("lookupdata", arraylistobj); in action class. ***)
    Assuming the java object has two properties, can I do the following
    <% for (iint i=0. i<objList.size;I++){ %>
    <td> what should i do here to get the first property of the object </td>
    <td> what should i do here to get the first property of the object </td>
    <% }
    %>
    if this approach is not proper, how can I pass the list of objects and parse in jsp?
    I am not sure what will be the name of the object. I can find out how many are there but i am not sure I can find out the name
    thanks a lot

    Double post:
    http://forum.java.sun.com/thread.jspa?threadID=5233144&tstart=0

  • How do I create an app from my Adobe pdf forms to use on any mobile device as well as windows and ios?

    How do I create an app from my Adobe pdf forms to use on any mobile device as well as windows and ios? I have all the apps in Creative Cloud by the way.

    If you already purchased it with the same Apple ID, then you will not be re-charged.

  • How do I move an object from one photo to another and then change the scene, i.e.  winter to sum?

    How do I move an object from one photo to another and then change the scene, i.e.  winter to summer?

    OK.
    Open the picture with the new scene. This will be your canvas.
    Open the picture with object A, select it with one of the selection tools, go to Edit>copy
    Go back to the new scene/canvas, Go to Edit>paste
    Repeat for object B
    Use the move tool to position A & B, each on its own layer. Use the corner handles of the bounding box to resize, if necessary
    You should have 3 layers: Background layer, and the 2 layers with A & B
    Note: It's best if the resolution of the 3 picture files is the same value.

  • How do I create a pdf from just one or two pages of an existing pdf?

    I just purchased this product (acrobat online)
    and it is not allowing me to do the things it promised, e.g. saving portions of one pdf to another, combining pages or entire docuements to create, even typing into a document (editing)! I am so frustrated - can someone please help!?

    But I jut paid $89.00 for the adobe pack - if I subscribe to Acrobat Plus, will that be credited?
    Date: Thu, 19 Sep 2013 15:50:14 -0700
    From: [email protected]
    To: [email protected]
    Subject: Files.Acrobat.com How do I create a pdf from just one or two pages of an existing pdf?
        Re: How do I create a pdf from just one or two pages of an existing pdf?
        created by H.Spector in Files.Acrobat.com - View the full discussion
    Hi,
    Thank you for your subscription.  If you are Acrobat Plus subscriber then you can extract the pages from the PDF file using Tools> Pages> Extract pages.
    You can find "Tools" at right top once you open your PDF file in Acroat.
    If you are subscriber to PDF Pack then please download Acrobat XI Plus from www.adobe.com.
    PDF Pack service offers "Convert to PDF", "Export from PDF"(to Word/PowerPoint/Excel/RTF formats so that you can edit the exported files) and "Combine Files" (combine your files into a single PDF file).
    Please let me know if you have any quesitons.
    thank you.
    hisami
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5697921#5697921
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5697921#5697921
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5697921#5697921. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Files.Acrobat.com by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Can you create an object from a string

    I have been working on creating a dynamic form, creating the
    form items from an xml file. I am getting very close to conquering
    this task. I will share it when it's complete.
    However, I am stuck at the moment trying to create an object
    from a string. For example, if the xml item is an HBox I want to
    create an HBox. Like this: parentObject = new arrayOfFormItems[
    index ]..type ()
    This isn't working. First, is this possible using some syntax
    I am unaware of in Flex? I don't want to use a large if or case
    statement if possible.
    Thanks in advance for your help!

    Thank you very much. Indeed that did solve the one problem. I
    missed the casting as a Display Object. That is awesome!
    I do still however, have to instantiate one of every item I
    want to dynamically create or I get the following error when I try
    to create a dynamic object that I have not instantiated before.
    ReferenceError: Error #1065: Variable HBox is not defined.
    at global/flash.utils::getDefinitionByName()
    at MyForm/buildForm()
    at DynamicForm/::onComplete()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    I read that you have no choice but to instantiate one of each
    type to force the linker to link the code for that class into the
    .swf. Unless you know another way to force it.
    This is what I have in my Application mxml to get it to work:
    <mx:HBox>
    <mx:Text visible="false"/>
    <mx:TextArea visible="false"/>
    <mx:TextInput visible="false"/>
    <mx:DateField visible="false"/>
    </mx:HBox>
    And those are the types I'm using to test with. . . I will
    have to add all the others I want to use as well . . .

  • How can I create a link from a CHM file to a webhelp file?

    How can I create a link from a CHM file to a webhelp file?
    The CHM output (accreditation.chm) is stored in a parent directory, and the webhelp output (index.htm) is stored in a child directory.

    Open the usual Link dialog and enter the relative path from where the CHM will be installed to where the webhelp will be installed.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • How can I create a object for a note?

    Hi experts,
        I need to apply the note 501905 but when I try in the SNOTE transacction I receive this error:
    Object REPS Z_MRM_DELETE_PP does not exist; create it
    Diagnosis
    The SAP Note that you want to implement contains changes to an object that does not yet exist in your system.
    SAP Notes contain only changes to objects that already exist. This means that the the system cannot automatically create new objects during the implementation of this SAP Note.
    Procedure
    1. Cancel the SAP Note implementationl.
    2. Create an empty object REPS Z_MRM_DELETE_PP with the corresponding object editor.
    3. Restart the SAP Note implementation.
    How can I create that Object??
    Thanks for the help!

    Hi Carlos,
    It says that you have to create a new program with a name Z_MRM_DELETE_PP.
    Once you create and activate the program you can execute the SAP Note.
    All this processure will be written in the SAP Note.
    Please Go through the Note using below:
    Step1: Use T.code SNOTE.
    Step2: Use menu GOTO --> NOTE BROWSER. Provide the Note no and EXECUTE.
    Step3: Double click on the displayed line.
    Here you will get the information to do before implementing the note.
    Go through all the documentation, and once you did all the development given in the note then you can implement the note.
    Regards,
    Sreekanth.

  • How to call a COM object from an Oracle Form?

    Hi All,
    Pls advice. How to call a COM object from an Oracle Form?
    Thanks.

    try asking the "Form" forum

  • How do I create a hyperlink from a tablet view to a desktop view in another muse site.

    How do I create a hyperlink from a tablet view to a desktop view in another muse site.
    The page keeps redirecting to a table view in the 2nd site.  There is no tablet view set up.

    Here's a similar thread that should clarify most of your doubts regarding linking pages between different layouts.
    http://forums.adobe.com/message/5147694
    Thanks,
    Vinayak

  • How do I create a ringtone from my music already on my iTunes database

    How do I create a ringtone from my music already on my iTunes database

    take a look at the link gives you detailed instructions to create ringtone and sync to yoru phone
    http://www.ehow.com/how_2160460_custom-iphone-ringtones-free.html

Maybe you are looking for

  • How do you upload playlists when your library size exceeds the ipod size?

    So I recently loaded more music onto my computer than my ipod can hold. Itunes created a new playlist, which the ipod is now using as the "library" that is uploaded into the ipod. That is all fine and dandy, but now my other playlists are no longer b

  • Source System Error for 0Material_Attr

    Hi Gurus, I have New BI System, when i m loading 0Material_Attr, the whole data is coming but with the status Red. May b the error is with source system. I checked in PSA maintenance and the error detail in source system is mentioned below. "Value 'A

  • Why is my website not working

    My website has been stopped and mobile me has a big CLOSED sign on the site. How do I reinstate my website with icloud?

  • LG optimus exceed 2

    My flashlight on the LG optimus exceed 2 has stopped working, haven't had this phone not even a month yet. Haven't dropped it in water or dropped it at all

  • "Service does not exist" Errors in CATS when entering Service PO

    Hi Experts, I'm currently working on the integration of CATS with MM-SRV. When I enter a timesheet with reference to a PO (containing items with service masters) in CATSXT, I receive an error message stating "Service does not exist". I've found OSS n