Extracting Directory Structure of System in Java

Please someone let me know that how can i extract the Directory Structure of the system (on which the application is running) in Java.
and then how can i display it in the Jtree .
The requirement is just like that of Windows Explorer.
In the Explorer we can see the complete directory structure of the system on left hand side.
Your help would be highly appreciated.
thanks in advance
Sakshi

Here's one place...
http://forum.java.sun.com/thread.jsp?forum=31&thread=441169
Regards,
  /Håkan

Similar Messages

  • Extracting Directory Structure of System

    Please someone let me know that how can i extract the Directory Structure of the system (on which the application is running) in Java.
    and then how can i display it in the Jtree .
    The requirement is just like that of Windows Explorer.
    In the Explorer we can see the complete directory structure of the system on left hand side.
    Your help would be highly appreciated.
    thanks in advance
    Sakshi

    This might be a starting point...
    http://developer.java.sun.com/developer/TechTips/1998/tt1117.html#tip2

  • Display of directory structure of remote system in GUI

    Hi All,
    I have the following requirement and request for your suggestion.
    I have two systems namely, A & B, on each of which a separate java program is running. And, these two programs are communicating to each other through RMI.
    The requirement is that, I have to show a GUI that displays the directory structure of system B from with in the program running on A.
    If any one has a solution for this, request you to please advice me on this.
    Looking forward for your help as early as possible.
    Regards
    Sekhar

    Thanks for your reply Ronillo.
    But, my requirement is like this.
    If you can spare few min. of your time, I will
    explain you my exact requirement.
    A & B are two systems conected in network.
    A & B are running programs (java) and program in A
    will make request to program in B thru. RMI.
    Now, one of these requests are... For transfering
    files on system B to system A.
    User working on A will make request for transfer of
    few files from System B to A.
    When he/she makes such request from System A, then a
    GUI (open file dialog box) shall get displayed on
    system A showing the directory contents of System B
    so that user can make selection of file(s) (that
    belong to System B) for file transfer.
    So for this, I need the "remote file chooser" kind of
    functionality.
    We are using java RMI for this.
    Your suggestions are most welcome on the possible
    implementation of this.
    Regards
    Naga SekharIm sorry for my late reply, Im busy with my thesis project. I dont know if what I think is right but, here please study the following:
    Just to list a few...
    01.) javax.swing.filechooser.FileFilter.
    02.) javax.swing.filechooser.FileView.
    03.) javax.swing.filechooser.FileSystemView.
    04.) java.net.URL.
    04.) java.net.URLConnection.
    05.) java.io.BufferedInputStream.
    06.) java.io.BufferedOutputStream.
    07.) java.io.FileInputStream.
    08.) java.io.FileOutputStream.
    09.) java.io.BufferedReader.
    10.) java.io.BufferedWriter.
    11.) Java Native Interface.
    You may create a custom file system view that you can pass to the constructor of file chooser. Google and read tutorials for more info.
    Okay? ^_^ God bless you all.
    Thank you -Ronillo

  • Directory structure for  ABAP+JAVA Dialog Instance

    Hello,
    Can any one clarify how will be the directory structure in a case where we have ABAP+Java System?
    For Central Instance,DVEBMGS<instance no>
    Central Services,SCS<instance no+1>
    Ex:DVEBMGS20
    SCS21
    If I have another dialog instance,can I have only ABAP or only Java in that?What will be the directory structure?But I read that they will be in 1:1 ratio
    Will it be D22(Only ABAP) or J22(Java only).
    As a dialog instance,can ABAP exist with out JAVA.
    or can JAVA exist without ABAP
    Please explain the directory structure with an example.
    Thanks,
    Sudheer.

    Sudheer,
    http://www.redbooks.ibm.com/redpapers/pdfs/redp4200.pdf page No 24 should help you...

  • Copying complete directory structure using java.io.File

    Is there a solution to problem when you want to copy a complete directory structure using java.io.File class as you can copy when using FTP connection.

    Is there a solution to problem when you want to copy
    a complete directory structure using java.io.File
    class as you can copy when using FTP connection.FTP does not have a command to transfer all the files in a directory. FTP clients implement this by invoking single file transfer for each file in a directory.

  • Sun recommended Java EE project directory structure?

    Hello,
    It's said that there's a Java EE project directory structure recommended by Sun.
    How to get it?
    I find a link as following,
    http://java.sun.com/blueprints/code/projectconventions.html
    The article is my want? Thanks!
    a cup of Java, cheers!
    Sha Jiang

    I got this worked out.

  • Creation of oracle directory structure on mounted file system in linux

    Hi,
    I need to use datapump utility for which directory structure would be required. since my dump files are stored another system i usually mount the file system, can i create oracle directory structure on mounted filesystem in linux? do suggest urgently. thanks in advance.

    Yes you can why not

  • System.setProperty("java.library.path")  question

    Is there a way to dynamically specify which directories the System.loadLibrary picks up its DLL's and libraries from ?
    I have read a few places saying no, however, WHY even have a System.setProperty("java.library.path") function? If there truly is not, then can there be a jni directory added to the WAR directory structure so that tomcat et. al. can access them

    Is there a way to dynamically specify which
    directories the System.loadLibrary picks up its DLL's
    and libraries from ?No.
    You can however use System.load().
    I have read a few places saying no, however, WHY even
    have a System.setProperty("java.library.path")
    function? That are many reasons for having setProperty(). For example if you want to set your own property.
    If there truly is not, then can there be a
    jni directory added to the WAR directory structure
    so that tomcat et. al. can access themBecause it extracts them into a directory which is in the OS path presumably.
    The OS, not java, loads shared libraries. And that means that the OS has to be able to find it. So JNIs are not loaded from a war/jar. They must be extracted first.

  • Import statement and directory structure

    First of all, sorry for such a long post, I believe part of it is because I am unsure of the concept of importing in Java. Secondly, Thanks to anyone who can ultimately enlighten me to the concept of import. I did ask this question before in the "erorr and error handling" forum, and the people who have helped me there did a great job. But, I believe I require a little more clarification and thus have decided to post here.
    Anyhow, my question..
    Could someone explain to me the concept of the import statement, or direct me to a webpage with sort of explanation for newbies? For some reason, I am having a hard time grasping the concept.
    As I understand it, the import statement in Java, is very similar to the namespace keyword in C. That is to say, import doesn't actually "import" any source code, the way that the #include statement does in C.
    So I suppose what my question is, say I have a java class file like below:
    //filename: sentence.java
    //located: c:\school\csc365
    package csc365;
    class sentence
    //some variables here..
    //some constructor here..
    //some methods here..
    And some sample program like the one below which implements the above..
    //filename: test.java
    //located: c:\school\csc365
    import csc365.*;
    import java.io.*;
    class test.java
    //creates some sentence object
    //uses the object's methods
    //some other things.
    As I understand it, the test.java file should not compile because the csc365 package is not in the correct directory. (assuming of course, the classpath is like c:\school\csc365;c:\school )
    But, ... where then should the sentence.java be located? In a subdirectory of c:\school called csc365 (i.e c:\school\csc365\) ?
    And thus that would mean the test.java file could be located anywhere on the hard drive?
    I suppose, I just need a little clarification on the correlation between a package's "name" (i.e package csc365; ) and its corresponding directory's name, and also how the javac compiler searches the classpath for java classes.
    ..So, theoretically if I were to set the classpath to look in every conceivable directory(provided the directory names were all unique) of the harddrive, then I could compile a test.java anywhere?
    As a note: I have been able to get the test.java file to compile, by leaving out the import statement in the test.java file, and also leaving out the package statement for the sentence class, but I assume this is because the files are defaulted to the same package?

    Hi Mary,
    No, import isn't analogous to C++ namespace - Java package is closer to the namespace mark.
    import is just a convenience for the programmer. You can go your whole Java career without ever writing an import statement if you wish. All that means is that you'll have to type out the fully-resolved class name every time you want to use a class that's in a package other than java.lang. Example:
    // NOTE: No import statements
    public class Family
       // NOTE: fully-resolved class names
       private java.util.List children = new java.util.ArrayList();
    }If you use the import statement, you can save yourself from typing:
    import java.util.ArrayList;
    import java.util.List;
    public class Family
       // NOTE: fully-resolved class names
       private List children = new ArrayList();
    }import isn't the same as class loader. It does not bring in any source code at all.
    import comes into play when you're compiling or running your code. Java will check to make sure that any "shorthand" class names you give it live in one of the packages you've imported. If it can't find a matching fully-resolved class name, it'll give you a message like "Symbol not found" or something like that.
    I arrange Java source in a directory structure that matches the package structure in the .class files.
    If I've got a Java source file like this:
    package foo.bar;
    public class Baz
       public static void main(String [] args)
            Baz baz = new Baz();
            System.out.println(baz);
       public String toString()
           return "I am a Baz";
    }I'll store it in a directory structure like this:
    root
    +---classes
    +---src
          +---foo
               +---bar
                    +---Baz.javaWhen I compile, I go to root and compile by typing this:
    javac -d classes foo/bar/*.javaI can run the code from root by typing:
    java -classpath classes foo.bar.BazI hope this wasn't patronizing or beneath you. I don't mean to be insulting. - MOD

  • Problem in retreiving directory structure, code needs correction

    hello there
    I am trying to fetch the directory structure of a particular directory in a way that the structure of subdirectories is also displayed.
    I have the following code:
    CODE:
    import java.io.*;
    public class FetchDir2
    static File dirStruct[][] = new File[300][100]; //stores the directory structure at a particular level
    static Integer pastIndex[] = new Integer[300]; //Stores index upto which a particular level has been scanned
    static String path = "C:/trydir"; //path of user's workspace, change it accordingly
    static int level = 0;
    static int index = 0;
    static int j=0;
    static int i=0;
    public static void main(String s[])
    File fileTry = new File(path);
    for(int i=0;i<300;i++)
         pastIndex=0;
    fetchStr(fileTry);
    public static void fetchStr(File fileTry)
    dirStruct[level] = fileTry.listFiles(); //fetch list of files and directories at this LEVEL
    sort(dirStruct[level]);
    for(i=0;i<dirStruct[level].length;i++) //loop to scan each element at this level
    if(dirStruct[level][i].isFile()) //if file is encountered
    System.out.println("Level:"+level+"\t Index:"+pastIndex[level]+"\t DirStruct.Length:"+dirStruct[level].length);//CHKPOINT
         System.out.println("<file>"+dirStruct[level][i].getName()+"</file>"); //print file element
         pastIndex[level]++; //increase the index at this level by 1
    //     if(dirStruct[level].length==0)
    //     {break;}
    //     else
         if(pastIndex[level]==dirStruct[level].length)
         System.out.println("</directory>");
         pastIndex[level]=0;
    level--;
         if(level==-1)
              break;     
    if(dirStruct[level][i].isDirectory())
    System.out.println("Level:"+level+"\t Index:"+pastIndex[level]+"\t DirStruct.Length:"+dirStruct[level].length);//CHKPOINT
         String path = dirStruct[level][i].getPath();
         File f = new File(path);
         System.out.println("<directory>PATH:"+path);
         pastIndex[level]++;
         if(pastIndex[level]==((dirStruct[level].length)-1))
         pastIndex[level]=0;
         level--;
         System.out.println("</directory>");
         else
         level++;
         //System.out.println("</directory>");
         fetchStr(f);
    public static void sort(File dirStruct[])
    for(i=0;i<dirStruct.length;i++)
    for(j=0;j<i;j++)
         int compare = dirStruct[i].compareTo(dirStruct[j]);
         if(compare>0)
         swap(dirStruct[i],dirStruct[j]);
    public static void swap(File f1,File f2)
    File f3;
    f3=f1;
    f1=f2;
    f2=f3;
    The dirctory structure used for testing is:
    <dir trydir>
    <file>f1</file>
    <file>f2</file>
    <file>f3</file>
    <dir d1>
    <dir d21>
    <file>f</file>
    </dir>
    <dir d22>
    <file>f</file>
    </dir>
    <file> f21</file>
    <file> f22</file>
    </dir>
    OUTPUT:
    Level:0 Index:0 DirStruct.Length:5
    <file>a1.txt</file>
    Level:0 Index:1 DirStruct.Length:5
    <directory>PATH:C:\trydir\d1
    Level:1 Index:0 DirStruct.Length:4
    <directory>PATH:C:\trydir\d1\d21
    Level:2 Index:0 DirStruct.Length:1
    <file>f31.txt</file>
    </directory>
    Level:1 Index:1 DirStruct.Length:4
    <directory>PATH:C:\trydir\d1\d21
    Level:2 Index:0 DirStruct.Length:1
    <file>f31.txt</file>
    </directory>
    Level:1 Index:2 DirStruct.Length:4
    <directory>PATH:C:\trydir\d1\d21
    </directory>
    Level:0 Index:2 DirStruct.Length:1
    <file>f31.txt</file>
    Can some one please correct this code.
    10 dukes are staright yours if you can.

    hi
    here is the code i work for u
    The code is changed and go through it
    import java.io.*;
    public class FetchDir2 {
        final static String path = "C:/web"; //path of user's workspace, change it accordingly
        public static void main(String s[]) {
            File fileTry = new File("c:/web");
            fetchStr(fileTry,0,0);
        public static void fetchStr(File fileTry,int level,int idx) {
            File dirList[]=fileTry.listFiles();
            sort(dirList);
            File f=null;
            System.out.println("Level:" + level+" Index:"+idx +" DirStruct.length:"+dirList.length);
            for(int i=0;i<dirList.length;i++){
                f = dirList;
    System.out.println("Level:"+level+" Index:"+i );
    if(f.isFile()){
    System.out.println("<file>"+ f.getName()+"</file>");
    else{
    System.out.println("<directory> Path:"+fileTry.getPath());
    fetchStr(f,level++,i);
    System.out.println("</directory>");
    public static void sort(File dirStruct[]) {
    int compare=0;
    for(int i=0;i<dirStruct.length-1;i++) {
    for(int j=i+1;j<dirStruct.length;j++) {
    compare= dirStruct[i].compareTo(dirStruct[j]);
    if(compare>0)
    swap(dirStruct[i],dirStruct[j]);
    public static void swap(File f1,File f2) {
    File f3;
    f3=f1;
    f1=f2;
    f2=f3;
    }Hopes it helps you...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Change Directory Structure Created in MPZIP file

    I'm trying to standardize my Multisim projects for inclusion in our documentation control system. As I build my project, I have a directory structure that I'm using. When I include the files in the project, the directory structure is remembered in the MPZIP file. However, the default is to unpack all files into the External(Project Name) folder. Following the help, 
    Extracted Path—The location to which the files will be extracted. The default is <project name>External\filename, for example project1External\amplifier.ms12. Use the drop-down lists in the Extracted Path column to select other locations as desired. 
    I can go in and change the directory path of each file using pull-down boxes. This makes  a manual process and if I include datasheets, specifications, and dxf files, is quite time intensive. Is there a way to default to having the project to unpack to the old directory structure? Is there some other way to automate the unpacking? I can manually zip the old project structure, but other than the form of the directories, the MPZIP is so convenient.
    Solved!
    Go to Solution.

    Hi Doug,
    When you unpack the project, the default is to create a new folder and put everything together since it is unlikely that the new computer will have the same file structure as the computer where this project came from.  If you want Multisim to create the same file structure as the original, you can click in the cell under "extracted path" and select the old path, if the folder doesn't exist, Multisim will create one.  Unfortunately, you will have to do this for each item on the table.
    Tien P.
    National Instruments
    Attachments:
    unpack.png ‏17 KB

  • Help me out with Directory structure for JSF+SPRING+HIBERNATE Project

    Hi frnds ,
    My name is Walter working for a startup software company . We are working on Hospital Management System (HMS) project .. MVC Architecture ...using Hibernate Spring and JSF ..we need to design Directory Structure for our project..
    plzz help me friends in suggesting MVC Directory structure ...? also plzz help me by directing me with the navigation flow?
    Thnxx in advance
    Regards
    Walter

    Thank you so much .. friends ..for your kind replies..thanks to Illu, anguquga and special thanks to BalusC for giving me the advice for hiring EE Artitech ..
    Anyways I have discussed with my teammates designing the directory structure
    anguquga your directory structure is close to what I have designed ..referiing to a sample application on web..
    Hospital Management system MVC architecture Directory structure
    This is the way the structure goes on ..
    model --> for Hibernate as well as Spring
    View --> for JSF
    src(-)
    |
    ------(-) java
         |
         -------(-) model
              |
              ------(+) businessobject
              |
              ------(-) dao
              |
              ------(+) hibernate
              |
              ------(+) exception
              |
              ------(-) service
              |
              ------ (+) impl
              |
              ------(+) util
              (-) view
              |
              ------(+) bean
              |
              ------(+) builder
              |
              ------(+) bundle
              |
              ------(+) servicelocator
              |
              ------(+) util
              |
              ------(+) validator
    (-) Web or WebRoot
    |
    ----- (-) JSP Files�etc.,
    |
    ----- (-) META-INF
    |
         ------     (+) Images
    |
         ------     (+) Scripts ==== CSS (cascading style sheets, JavaScript files etc.,)
    |
    ----- (-) WEB-INF =========xml files web.xml, faces-config.xml etc.,
         |
         -----(-) Classes
              |
    -----(-) HMS
    |
                   ----- (+) model
                   |
                   ----- (+) view
    |
    ----- (+) lib
    I am sure you may notice few errors .. if u find any plzz reply me back.... thnxx in advance for replies...and thnxx for giving your valuable replies...
    Walter (Kaleem)

  • Directory Structures

    Hi,
    This is about the directory structures to use for development and
    deployment under weblogic. By default, as you all know, weblogic comes with
    a server called "myserver" whose directory strcuture has within it the
    public_html, serverclasses, servletclasses and clientclasses directories,
    with the jar files for the examples all residing in the myserver directory.
    The general tendency for developers is to use simply use that very structure
    as is. I think that may prove to be unwieldy during deployment (especially
    when there will be multiple servers running on multiple machines, etc.) as
    well as during development (integrating with source code control, etc.)
    Here are my questions:
    1) How have people weblogic developers organized their directory structures
    for deployment? It seems to me that it would make sense to have a directory
    structure that has at least a "lib" directory under which the jar files were
    put, a "log" directory for log files, a "cert" directory for certificates,
    etc.
    2) In addition, is there an absloute need for the myserver directory to sit
    under the weblogic tree? I would think it would make sense to not have the
    deployment directory structures not tied to the weblogic installation's
    location.
    3) If there are multiple servers that will be deployed (each instantiating
    its own set of services that are implemented as session and entity EJBs),
    does one introduce an entire directory structure for each server or have a
    common directory structure with each server having its own properties file ?
    Currently, I have it setup so that each server that is introduced, e.g.,
    pricing servers, fulfillment servers, etc. has its own properties file and
    that the entire directory tree sits separate from the weblogic installation,
    to facilitate tight integration with source code control. Having resolved
    the regular issues that arise with the CLASSPATH, ClassCastExceptions, etc.,
    we're up and running, but I have had a tough time convincing my developers
    about the merits of deviating from the standard development tree stcucture.
    Do people have any opinions about this, and are there any experiences they
    can share with me? I'd be more than willing to to change course based on
    others' experiences.
    Sorry for the long-winded message.
    TIA,
    Prashanth

    Prashanth Nandavanam wrote:
    >
    Hi,
    This is about the directory structures to use for development and
    deployment under weblogic. By default, as you all know, weblogic comes with
    a server called "myserver" whose directory strcuture has within it the
    public_html, serverclasses, servletclasses and clientclasses directories,
    with the jar files for the examples all residing in the myserver directory.
    The general tendency for developers is to use simply use that very structure
    as is. I think that may prove to be unwieldy during deployment (especially
    when there will be multiple servers running on multiple machines, etc.) as
    well as during development (integrating with source code control, etc.)
    Here are my questions:
    1) How have people weblogic developers organized their directory structures
    for deployment? It seems to me that it would make sense to have a directory
    structure that has at least a "lib" directory under which the jar files were
    put, a "log" directory for log files, a "cert" directory for certificates,
    etc.That's how I'd do it. I think that the locations of all the
    resources you need are configurable. If they're not, let us know.
    2) In addition, is there an absloute need for the myserver directory to sit
    under the weblogic tree? I would think it would make sense to not have the
    deployment directory structures not tied to the weblogic installation's
    location.No, it can be anywhere you like. Make sure you adjust the security
    policy
    file so Java 2 will let the server access your classes.
    3) If there are multiple servers that will be deployed (each instantiating
    its own set of services that are implemented as session and entity EJBs),
    does one introduce an entire directory structure for each server or have a
    common directory structure with each server having its own properties file ?
    Currently, I have it setup so that each server that is introduced, e.g.,
    pricing servers, fulfillment servers, etc. has its own properties file and
    that the entire directory tree sits separate from the weblogic installation,
    to facilitate tight integration with source code control. Having resolved
    the regular issues that arise with the CLASSPATH, ClassCastExceptions, etc.,
    we're up and running, but I have had a tough time convincing my developers
    about the merits of deviating from the standard development tree stcucture.The "standard" directory tree exists only for the purpose of running
    the examples that are shipped with WLS. The WebLogic development
    team does exactly what you propose to do, and for the reasons you
    state: to keep our deployment configuration under source control in a
    location that keeps it separate from the examples support in myserver
    and to make it easy to re-install the server without disturbing our
    configuration files. We routinely run WebLogic Server from a
    configuration
    that completely ignores the WEBLOGICHOME/myserver directory.
    Do people have any opinions about this, and are there any experiences they
    can share with me? I'd be more than willing to to change course based on
    others' experiences.
    Sorry for the long-winded message.
    TIA,
    Prashanth--
    Chuck Karish BEA Systems
    (415) 402-7692 http://www.bea.com/

  • Making a Directory Structure with JTree.

    Hello,
    Can anyone boss here help me to code to make a
    File System Directory structure through JTree?
    The outlook should be like the Windows Explorer...
    From : [email protected]

    * HarishTree.java
    * Created on September 7, 2004, 2:56 PM
    * @author 120002314
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import java.io.File;
    import java.awt.event.ActionListener;
    import javax.swing.JToolBar;
    import java.lang.System;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import javax.swing.filechooser.FileSystemView;
    public class HarishTree {
    public static void createAndShowGUI() {
    //creating a tree with drives in the toolbar
    TreeBar bar = new TreeBar();
    JScrollPane scrollpane = new JScrollPane(bar.tree);
    JToolBar toolbar = bar.CreatingTreeBar();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(toolbar);
    // Display it all in a window and make the window appear
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("FileExplorer");
    frame.getContentPane().add(scrollpane, "Center");
    frame.getContentPane().add(panel,BorderLayout.NORTH);
    frame.setSize(400,600);
    frame.setVisible(true);
    frame.setResizable(false);
    public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    java.lang.System.gc();
    * The methods in this class allow the JTree component to traverse
    * the file system tree and display the files and directories.
    class FileTreeModel implements TreeModel {
    // We specify the root directory when we create the model.
    protected JFile root;
    public FileTreeModel(){}
    public FileTreeModel(JFile root) { this.root = root; }
    // The model knows how to return the root object of the tree
    public Object getRoot() { return root; }
    // Tell JTree whether an object in the tree is a leaf
    public boolean isLeaf(Object node) {  return ((JFile)node).isFile(); }
    // Tell JTree how many children a node has
    public int getChildCount(Object parent) {
    String[] children = ((JFile)parent).list();
    if (children == null) return 0;
    return children.length;
    // Fetch any numbered child of a node for the JTree.
    // Our model returns File objects for all nodes in the tree. The
    // JTree displays these by calling the File.toString() method.
    public Object getChild(Object parent, int index) {
    String[] children = ((JFile)parent).list();
    if ((children == null) || (index >= children.length)) return null;
    return new JFile((JFile)parent,children[index]);
    // Figure out a child's position in its parent node.
    public int getIndexOfChild(Object parent, Object child) {
    String[] children = ((File)parent).list();
    if (children == null) return -1;
    String childname = ((File)child).getName();
    for(int i = 0; i < children.length; i++) {
    if (childname.equals(children)) return i;
    return -1;
    // This method is invoked by the JTree only for editable trees.
    // This TreeModel does not allow editing, so we do not implement
    // this method. The JTree editable property is false by default.
    public void valueForPathChanged(TreePath path, Object newvalue) {}
    // Since this is not an editable tree model, we never fire any events,
    // so we don't actually have to keep track of interested listeners
    public void addTreeModelListener(TreeModelListener l) {}
    public void removeTreeModelListener(TreeModelListener l) {}
    class TreeBar implements ActionListener{
    public JTree tree = new JTree();
    public File[] roots = File.listRoots();
    JToolBar toolbar = new JToolBar();
    public TreeBar(){
    FileTreeModel model = new FileTreeModel(new JFile(System.getProperty("user.home")));
    tree.setModel(model);
    tree.setCellRenderer(new MyRenderer());
    public JToolBar CreatingTreeBar(){
    for(int i=0;i<roots.length;i++){
    JButton button = new JButton(roots[i].getPath(),new MyRenderer().inicon);
    button.addActionListener(this);
    button.setActionCommand(roots[i].getPath());
    toolbar.add(button);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    return(toolbar);
    public void actionPerformed(java.awt.event.ActionEvent e) {
    FileTreeModel model = new FileTreeModel(new JFile(e.getActionCommand()));
    tree.setModel(model);
    class MyRenderer extends DefaultTreeCellRenderer {
    ImageIcon inicon = createImageIcon("1.gif");
    ImageIcon exicon = createImageIcon("2.gif");
    ImageIcon leaficon = createImageIcon("3.gif");
    public ImageIcon createImageIcon(String path) {
    java.net.URL imgURL = TreeIconDemo2.class.getResource(path);
    if (imgURL != null) {
    return new ImageIcon(imgURL);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    public Component getTreeCellRendererComponent(
    JTree tree,
    Object value,
    boolean sel,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    if (leaf){
    setIcon(leaficon);
    }else
    if(expanded)
    setIcon(exicon);
    else
    setIcon(inicon);
    return this;
    class JFile extends File{
    public JFile(String path){
    super(path);
    public JFile(File parent,String child){
    super(parent,child);
    public String toString(){
    FileSystem fs = new FileSystem();
    if(fs.isFileSystemRoot(this))
    return(this.getPath());
    else
    return(fs.getSystemDisplayName(this));
    class FileSystem extends FileSystemView{
    public File createNewFolder(File containingDir) throws java.io.IOException {
    return(this.createFileObject(containingDir,"harish"));

  • Is there a fixed directory structure where we put our application?

    the samples .java files I find in \ias6\ias\ias-samples\database\hellodb\src\samples\hellodb\servlet ...
    I need to know if there is a directory structure that I should follow that iPlanet need when I deploy my application? like where do I put my .jsp files, .java or any beans class ? or it does not matter because these would be in the WAR file ..

    It does not matter how your directory structure is for your applications. When you deploy the war/ear files, all your class files and JSPs will be extracted from the war/ear files under ias_root_dir/ias/APPS

Maybe you are looking for