• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to find all imported classes in java file?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a big application. In that application there are many packages and each packages have many java files.
I want to compile a single java file that has many dependants classes in application.I want to make a jar file of all the dependant classes.
How can i know how many dependant classes are there for java file???

For Example.
I have ClassA,ClassB,CLassC,ClassD,ClassE.
and all classes are in different packages.

ClassA has imported ClassB
ClassB has imported ClassC
ClassC has imported ClassD
ClassD has imported ClassE

now to compile class ClassA we require ClassB,ClassC,ClassD,ClassE.
Here we can can find all dependaent classes for ClassA because its a small example but in big application we can not search each references explicitly..
So please if anybody knows any tricks or any tools to find dependant classes please tell me..
Thanks in Advance
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"hiren01it", please check your private messages. You can see them by clicking My Private Messages.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if FatJar does what you need. It might drag in whole jars when you only need a few classes.

I use the JDepends dependency tool plus a script that reads through the report to extract simple "a depends on b" data. I write a DOT file for GraphViz but you could surely make a jar or zip script.

None of these things will find classes you load through Class.forName(xxx).newInstance(). I tend to do quite a bit of that with factories configured through properties or whatever.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"hiren p" - please check your private messages again.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic