We have developed a J2EE application where the "client" is a java
application. In other words, we have created a JAR file that a user
uses to launch our application. The manifest for this JAR file has a
"Main-Class" attribute, so the following command is used to launch the
(client side of) the application:
java -jar our.jar
Our entire application (both client-side and server-side) consists of
several hundred classes. Our problem is that we don't have an accurate
list of which classes are client-side only, which classes are
server-side only, and which classes are required by both (client-side
and server-side). I want our client-side JAR to only contain classes
required by the client. Currently, we are simply bundling all the
classes into "our.jar".
I have found (and tried) several utilities, including:
However, I don't think these are suitable. You need to supply a class
name, and they only tell you the classes that either depend on the
given class, or that the given class depends on. What I want is a
"recursive" dependency finder.
For example, let's say I have class "A". Class "A" depends on class "B"
(in other words, class "A" needs to import class "B"). Now class "B"
depends on class "C" and class "C" depends on class "D". Also, we have
class "E" that depends on class "A" (in other words, class "E" needs to
import class "A").
The tools I mentioned above will only return (at most), classes "B" and
"E" (when I supply them with class "A"), but what I really need them to
return is classes "B","C" and "D" (and not necessarily class "E").
We use GenJar (http://genjar.sourceforge.net) and that works very well.
Included as Ant task in our build script it jars all our clients and servers.
It will even unpack library jars and include the classes in your application jar ;)
But you can specify which packages it should leave outside the jar it creates.
Just because I awarded Paschilke the Duke Dollars, doesn't mean you should give up on this thread. I am quite willing to award more Duke Dollars to anyone who can provide a good, alternative solution. The thing I don't like about "GenJar" is that you can only use it as an Ant task.
ClassDep from jini provides the same functionality as GenJar but I have found it better to work with. You do not need ant to run it although it does come with an ant task. ClassDep.java has a public static void main (String args ).
http://java.sun.com/products/jini/2.0/doc/api/com/sun/jini/tool/ClassDep.html provides the documentation on how to use it.
and class B changes, must we also provide class A for product fix?
if class A is imported by class F, then we must include who?
but if class A changes, we do not care about class B correct - only class F?