Search code examples
javafilefile-iojarclassloader

How to get class file structure in the other project


Imagine a project with files looks like:

   llib
    ├── com.jar
    ├── utlib
    │   ├── rd
    │   │   ├── d.jar
    │   │   └── r.jar
    │   └── u.jar
    └── weblib
        ├── a.jar
        └── b.jar

Imagine com.jar should have a stucture:

com
├── C.class
├── META-INF
│   └── MANIFEST.MF
├── util
│   ├── A.class
│   └── B.class
└── web
    ├── H.class
    └── S.class

I need to get the file structure in other project, and get class file structure of each jar file in this project. The result should be returned as a tree as above. How to do that?

EDIT:

Browse a project folder and build the folder structure as a tree. If there is jar file, build its class structure as a subtree. Programming in java and return a tree including folder structure and class structure. My output result should looks like:

llib
├── com
│   ├── C.class
│   ├── META-INF
│   │   └── MANIFEST.MF
│   ├── util
│   │   ├── A.class
│   │   └── B.class
│   └── web
│       ├── H.class
│       └── S.class
├── utlib
│   ├── rd
│   │   ├── d
│   │   │   └── subd
│   │   │       ├── D1.class
│   │   │       └── D2.class
│   │   └── r
│   │       └── R.class
│   └── u
│       └── U.class
└── weblib
    ├── a
    │   └── suba
    │       └── subaa
    │           └── SA.class
    └── b
        ├── B1.class
        ├── B2.class
        └── B3.class

Solution

  • Ok to browse the folder see this.

    And to browse the jar (when detected) see this

    Hope this helps.