Resolving file names from java package

Hello Everyone,
I was wondering if there is a way to get the names of all the java classes inside of a package from my app. What I would like it to do, is to read the names of the classes in the package, and then use reflection to create an instance of each. At the moment, I have a properties file that contains all the class names. The app reads the file and uses reflection to create an object of each. This is not as good for me because i would rather be able to drop a new class into the package and have it work instead of having to edit the properties file first.
So, is it possible get the list of files that are contained in a package?
Thanks,
Bryan Campbell

So, is it possible get the list of files that are
contained in a package?No, but why not let the application scan a folder?
Kaj

Similar Messages

  • How can i get all java class names from a package using reflection?

    hi,
    can i get all classes name from a package using reflection or any other way?
    If possible plz give the code with example.

    You can't, because the package doesn't have to be on the local machine. It could be ANYWHERE.
    For example, via a URLClassLoader (ie from the internet) I could load a class called:
    com.paperstack.NobodyExpectsTheSpanishInquisitionI haven't written it yet. But I might tomorrow. How are you going to determine if that class is in the package?
    This subject comes up a lot. If you want to do something a bit like what you're asking for (but not quite) there are plenty of threads on the subject. Use google and/or the forum search facility to find them.
    But the answer to your question, as you asked it, is "you can't do that".

  • Problem on how to create a .h file in a java package !!

    Hello,
    Please help me!! I have a problem generating a header file inside a java package. As I do not think eclipse IDE can do that, I then have to use the command as following in the command prompt instead.
    D:\myJava\workspace\myJNI\bin>javah sysHookJNI/PollThread
    javadoc: error -Illegal package name "sysHookJNI/PollThread"
    sysHookJNI is my package name and PollThread is my class name. I think it should works because I compiled it with similar format as>java sysHookJNI/PollThread.java and it outputs the PollThread.class, but in fact it doesnot !>_<.
    Can anyone suggest me what I should do?
    Big thanks in advance,
    Neth

    Thank you so much !!
    But after I got that point my old problem is still not solved with that. After my sysHookJNI.PollThread.h is generated, I compiled everything over and then run Test by
    : java Test and the Exceptions are occurred as:
    Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: sysHookJNI.PollThread.checkKeyboardChanges()V     at sysHookJNI.PollThread.checkKeyboardChanges(Native Method)
         at sysHookJNI.PollThread.run(PollThread.java:21)
    And this is my PollThread.java (actually I took it from Jacob )
    //PollThread.java
    package sysHookJNI;
    import java.io.*;
    public class PollThread extends Thread
         public native void checkKeyboardChanges();
         private KeyboardHook kbh;
         public PollThread( KeyboardHook kh )
              kbh = kh;
              System.loadLibrary("syshook");
         public void run()
              for(;;)
                   checkKeyboardChanges();
                   yield();
         void Callback( boolean ts, int vk, boolean ap, boolean ek )
              KeyboardEvent event = new KeyboardEvent( this, ts, vk, ap, ek );
              if( ts )
                   kbh.keyPressed( event );
              else
                   kbh.keyReleased( event );
    }Anyone has any suggestion about this problem? I really have no clue about it!! it keeps complains the same things no matter I regenerated header file or not.. T_T
    Btw, shall I make a new post about this problem?
    Thanks for your time,
    Edited by: Nethie on Nov 1, 2009 2:37 PM

  • Determining File Name in Info Package under External Data

    Determining File Name in Info Package under External Data
    I am on SAP BW 3.0. A System is sending a flat file every few days
    With a date time stamp, e.g., d:\loaddar\file_20080212_122300.csv
    I know in Info Package one can create routine under external data to determine the file name. I have seen
    Examples where people determine file name based on date. Since my file has a time stamp, what code  I write a  to pick the file. Is there a way to read one or more files and
    Determine file name.
    I am new to SAP BW and ABAP. However, I have lot of experience with Oracle and Java.
    Can someone point me how this will be done. I am looking for some sample code as well.
    Thanks in advance. I will really appreciate your help.

    Hello Prem,
    Even i used to get the file suffix with date & time, and i found very difficult to pick up the file from application server using routine in infopackge. Then i asked to change to date only and it was easy to pick the file using routine. But i think in your case files are coming more than once, in such a case you should write a small unix script to add these files and then convert into single file with date only and execute the infopackage to load it.
    Cheers!
    Sanjiv

  • Remote File accessing from java WebNFS

    Hi
    I am using java WebNFS package provided by sun to access the remote file system from java class. A class called com.sun.xfile.XFile does this functionality and it is almost similar to java.io.File. My issue is I am trying to lookup a Windows NT File Server through the XFile constructor and list out all the files in a particular directory. When I run the sample class from a Windows Machine it is working fine. But when I run the same class from a Linux machine, the XFile class couldnt resolve the path. Do those Linux server and the Windows NT File server should have been mounted ? Suggestions are welcome. Thx in advance.

    viswa07 wrote:
    Ya Darryl.Thanks for ur reply.Tell me now how to do that action..????What Darryl is pointing out is that no one is going to reply to you because you have a history of not replying to questions - think about it - if someone asked you a question and you asked them a question to help you understand what they were asking and they walked away, and then did that again - would you keep trying to help?

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • File Name in Java Map

    Hello,
    I want to add the time stamp in the file name in JAVA map.
    Actually we are directly writing the file on to the file system from Java map and also giving its output to other map.
    So we need when we write the file on the file system the file name should be ABC_timestamp.
    Can anyone help me how to do this in Java Map.
    Thanks and Regards
    Hemant

    Hi,
    >>>Actually we are directly writing the file on to the file system from Java map and also giving its output to other map.
    are you sure you want to do this?
    this is highly inadvisable as mappings do not support restarts and any error handling
    further more what if the mapping will crash but the file will be created?
    if you restart the mapping you will get a second file?
    I'd recomment not doing anything like that - maybe think about your scenario once more ?
    Regards,
    Michal Krawczyk

  • Can we possible to retrive the file name from the directory...?

    Can we possible to retrive the list of files or file names from the directory...?
    The directory called create or replace directory [directory_name] as ....

    Yeah, yeah its very good example for this scenario.
    I agree. But, I want to learn about Java based PL/SQL code development for that just I am asking any link for this kind of material.....:-)

  • Keeping file name in picture package

    Hi guys,
    iam struggling through picture package at the moment,
    what i would like to do is to keep the original file name in picture package then when the new files are generated not have to type the old name back in some of the names can be quite elaborate.
    Ny62456_IMG for instance i don't mind dropping the IMG but want to keep the file names
    thanks
    Nik

    the images are coded
    so that i know where they come from for instance the filename will start with the schools name SK then the yearY6 then the jpeg number the filename would be SKY62109 therefore i know where it has to be sent.
    Maybe i am talking complete nonsense to you but in photoshop it works to a reasonable standard and each image is copied and then copy is generated by photoshop after each image. Its just that photoshop is not quick enough or stable enough to process a lot of images
    If i exported the file then it would retain the filename
    If you can think of a better way of doing this then please tell me i actually started playing with lightroom last saturday so am a beginner
    Nik

  • How to delete file names from Adobe Reader list

    How can I delete file names from the Adobe Reader list?  I have deleted the file & it's empty, but deleted file names remain in my list & it's very annoying.  I can't seem to find an option anywhere to delete the file names.

    Thanks for the answer, I will try this & post my results with this method.  I have set the amount to zero, & it seems if I want to put back valid files into my list I first need to find them in another file in my pc, such as documents, open them in Adobe Reader, & then then they will reappear in the Adobe Reader list.  Is this correct?  Thank you!
    This seems to be the case, you need to restore each file you want in your list one by one by accessing them elsewhere on your pc, & then you must open them with Adobe Reader to have files reappear in your Adobe Reader list.  However, this seems to be a tedious process if you only want to delete one obsolete file from your list by first emptying the list & rebuilding it file by file.  It works, but I'm wondering if there is a more sensible & efficient way to do this?

  • File name from a path

    hi ,
    there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
    but i had to write a dynamic code which can get the file name from any given path.

    Smoke me a kipper, I'll be back before breakfast.
    SQL> var extended_filepath varchar2(128)
    SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
    PL/SQL procedure successfully completed.
    SQL> select instr(:extended_filepath, '/', -1)
      2  from dual
      3  /
    INSTR(:EXTENDED_FILEPATH,'/',-1)
                                  21
    SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
      2  from dual
      3  /
    SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
    file.txt
    SQL> Cheers, APC

  • Retreiving the file names from directory inside another directory from application server

    Hi,
    I had a problem in retreiving the file names from a directory inside another directory.
    I tried using the FM's  SUBST_GET_FILE_LIST, RZL_READ_DIR_LOCAL and EPS_GET_DIRECTORY_LISTING
    But here I am getting only one directory details.
    Actually my file is located a directory inside one more directory and one more directory and inside the files are located.
    i.e total 3 directories inside the 3rd one my files are there.
    I need to read the latest file name in the directory.
    So that i can do some manipulation after getting the file name.
    Is there option like OPEN DATASET , READ DATASET and CLOSE DATASET?
    Can anyone please let me know How can i acheive this one.
    Regards
    Ram

    Hi Ram,
        Following thread can be helpful for you, were it shows in the tables structure rsfillst a field RSFILLST-TYPE whether its a directory or file..........
    http://scn.sap.com/thread/865272
    thanks and regards,
    narayan

  • Flat file name from Sender Side Dynamically into subject of Receiver Mail

    Hi All,
             I am Using a file to Mail Scenario, My requirement is to get dynamically the file name from flat file of the Sender Side into Subject of Receiver Mail Adapter and attachment of file from the Sender Side. Can anyone help me out.
    Thanks in Advance

    Hi....
              You can write udf in the message mapping to get the Dynamic file name and map that to the subject of the receiver mail.
      DynamicConfiguration conf = (DynamicConfiguration) param.get(
              StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
          // read value
          String Filename = conf.get(KEY_FILENAME);
    Regards,
    Leela

  • How to get the file name from Oracle B2B 10g

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

Maybe you are looking for

  • Extractor for RSEG incoming invoice table

    Does anyone know if there is a standard extractor that includes incoming invoices from table RSEG?  Also is there documentation somewhere on all of the standard extractors?

  • SQL Statement error when running ETL from DAC

    Dear all, I installed and configured biapps 7.9.6.3, then I run the full load of Subject CRM - Loyalty in DAC. And I got the error of task fail, I check the Session log files in Informatica server. $ view SEBL_VERT_811.DATAWAREHOUSE.SDE_SBL_Vert_811_

  • Iweb ftp can't connect to server

    I have been using iWeb for a long time to manage my web sites without any problems, however when I recently tried updating my web sites, I get a message from iWeb saying that it cannot connect with my host server. I am running Snow Leopard 10.6.8 and

  • Help install jwsdp 1.0 and run JAX-RPC  example

    I installed jwsdp1.0 today and I tried to run the Hello world example for JAX-RPC (http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXRPC3.html). The problem is with any command passed at the console (ant command or startup (tomcat), deploytool

  • BICS_PROV_GET_INITIAL_STATE and form Variables are not submitted

    Hi Team, We are geting following error message while running WAD reports on BI QA and Test system portal. Our issue is similar to the issue mentioned in SDN thread BICS_PROV_GET_INITIAL_STATE Exception - We are facing issue in refreshed systems. - Va