Board index » jbuilder » Which libraries to include??

Which libraries to include??


2003-09-19 08:21:40 AM
jbuilder23
Hi,
using JBuilders archive builder i would like to know which option i should
choose when adding libraries:
1. never include
2. include required and know resources
3. include required and all resources
4. always include all classes and resources
I do use jbuilder libraries i my program.
Thanks
Rudy
 
 

Re:Which libraries to include??

On 9/18/2003 at 8:21:40 PM, Rudy wrote:
Quote
using JBuilders archive builder i would like to know which option i
should choose when adding libraries:
1. never include
2. include required and know resources
3. include required and all resources
4. always include all classes and resources
That depends.
You can choose "never include" and then distribute the library JAR file
along with your application JAR file. Some licenses prohibit you from
repackaging a library, so this may be the only choice.
If you want to include the classes from the library in the JAR file you
are generating, you will use one of the other settings. To understand
which to use, you need to understand how the Archive Builder tries to
figure out which classes and resources to include. And in order to
understand that, you will need to understand how a Java program locates
classes and resources that it uses.
In general, the Archive Builder starts with a given set of classes that
it knows that it will include in the archive. It then goes through
those classes, finds references to other classes, and tries to include
those in the archive too. It also searches those classes for
references and the classes that it references, and so on.
The question is, how does it determine which classes are referenced by
a given class? In most cases, a program refers to another class by
specifying the name of that class directly in the source code. For
example:
Rectangle r = new Rectangle();
In these cases, it is very easy for the Archive Builder to determine
that a given class is needed. The archive builder will always
recognize that these classes are needed.
But that is not always the case. Classes are sometimes loaded by
specifying the name of the class as a string. For example:
Class.forName( "org.postgresql.Driver" );
In this case, the name of the class is specified as the argument to the
Class.forName() method. The code does not actually contain an actual
reference to the class, just a string that holds its name. You might
think that the Archive Builder could be smart and recognize such calls,
but it can be even less obvious than that. For example:
String driver = System.getProperties( "database.driver" );
Class.forName( driver );
Here, the name comes from an external system property, which might be
specified on the command line that runs the program. Obviously, there
is no way forthe Archive Builder to determine the value, so it cannot
know which class will be loaded by this statement.
Resources (.properties files, images, etc) are loaded using a mechanism
like this (such as the ClassLoader.getResource() method), so it is also
impossible for the Archive Builder to always determine which resources
will be needed.
In the options you listed above, the terms "required classes" and
"Known resources" refer to those that the Archive Builder is able to
recognize. If you know that the classes and resources are loaded using
mechanisms that the Archive Builder will recognize, you can specify one
of these.
If you specify "always include all classes and resources", then the
Archive Builder will include everything from the JAR file. That will
guarantee that nothing that is needed will be left out, but it also may
result in a lot of classes and resource being included that you will
not need.
The approach you use will depend on a number of things, such as license
requirements, how important it is to minimize the size of the archive,
how sure you are about how the library operates, etc.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html