Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find all imported classes in java file?

 
hiren parghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"hiren01it", please check your private messages. You can see them by clicking My Private Messages.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"hiren p" - please check your private messages again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic