Solved

Libaray Settings in JAR files

Posted on 2004-09-08
26
453 Views
Last Modified: 2013-11-23
Hey experts,

I am using JBuilder 6.0, and I am creating a JAR for my applet. When you are setting the Libarary settings for each of the components that you are including in the JAR there are four options:

1- Never include any classes or resources.
2- Include required classes and known resources
3- Include required classes and all resources
4- Always include all classes and resources

Can someone explain the difference between these options (when to chose each), and more importantly the difference between a class and a resource.

0
Comment
Question by:mte01
  • 10
  • 10
  • 4
  • +1
26 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>and more importantly the difference between a class and a resource.


Well i can answer that bit. A 'resource' is effectively any file required by your app that *isn't * a class. e.g. text files, images etc.
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
The probelm that I am facing here is that unless I include all the classes and resources (4th option) the browser wouldn't run the applet (it wouldn't find a Borland class that I am using). Moreover, including all these classes takes time in the compile process when you are testing your program, so what I need to know is that why do I need to include all the classes (why not only the required ones) when creating the JAR file.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 20 total points
Comment Utility
>>so what I need to know is that why do I need to include all the classes

Well that's trickier than it appears. OK - *you* can see which classes *you're* using but there will probably be internal dependencies. Always safer to use the lot
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
Okk I see.

I'll keep the question open for a few hours to see if someone can have a better solution and then give the proper credit.
0
 
LVL 9

Assisted Solution

by:doronb
doronb earned 100 total points
Comment Utility
Taken straight from JBuilder's help documentation:

"Determine what to do with library dependencies

This step of the Archive Builder and Native Executable Builder is where you determine what to do with library dependencies. The libraries used in your project are listed, and you can choose an individual deployment strategy for each one.

* Never Include Any Classes Or Resources:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the default option for all archive types except applets. No libraries are included in your archive file. You need to distribute the redistributable libraries with your JAR file and include them on the CLASSPATH at runtime, rather than putting the required classes from those libraries inside the JAR file. This is the easiest way to deploy and creates the smallest program JAR file. If you choose this option, Exclude All is displayed next to the selected library.

* Include Required Classes And Known Resources:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you choose this option, the Archive Builder attempts to determine which classes and resources are needed and attempts to include them. It also attempts to include any resources that are used by any classes in your project. Note that this process does not work for many libraries. Typically, the next option, Include Required Classes And All Resources, is a better choice for library deployment. If you choose this option, Include Deps is displayed next to the selected library. Note: Deps represents dependencies.

* Include Required Classes And All Resources:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you choose this option, the Archive Builder attempts to determine which classes are needed by classes in your project and attempts to include them. It also gathers all resources on the project's source path set on the Paths page of the Project Properties dialog box. Usually, this is set to the src directory of your project. Resources are files other than class files, such as images, video clips, and sound files. You can also change JBuilder's default settings for resources and specify individual files or file extension types to be copied to the output path with the class files during compile. See the "Selective resource copying" topic in "Building and compiling Java programs." This option is useful if you are deploying third-party libraries. This option is the default option for the Applet archive type. If you choose this option, Deps & Resources is displayed next to the selected library. Note: Deps represents dependencies.

* Always Include All Classes And Resources:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This option gathers all classes and resources, whether they are dependent or not. Everything, including libraries used by JBuilder's designers, is copied to your archive file. You can also change JBuilder's default settings for resources and specify individual files or file extension types to be copied to the output path with the class files. See the "Selective resource copying" topic in "Building and compiling Java programs." Important: Although this option is the safest, it results in a very large archive file. If you choose this option, Include All is displayed next to the selected library"
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
Ahaa Thank you.....but I still don't see why including the required classes won't make the applet run in the browser (see my 1st comment)
0
 
LVL 9

Expert Comment

by:doronb
Comment Utility
I think that JBuilder can't correctly discover the correct dependency tree for your applet.

Is your applet a signed applet?
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
I've heard of signed software, but signed applets???
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
>>Is your applet a signed applet?
I think this problem may not be related with signed applet
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
mte01

Actually what dependency classes u need to include in your jar file??
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
I imported
com.borland.jbcl.layout.XYLayout;
com.borland.jbcl.layout.XYConstraints;

which are the ones that I used directly, and in the JAR file settings I chose "Include required classes and all resources" in the dependency tab, but when I run my applet in the browser it won't find the XYLayout class. When I include all classes, the problem doesn't occur, and the program runs smoothly.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
OK I suggest you one rude manual rude operation

If u know the jar file of that classes

<applet code=YourApllet.class
      archive="yourclasses.jar ,  borlandjar.jar"
      width=460 height=160>
      <param name=foo value="bar">
    </applet>

0
 
LVL 3

Author Comment

by:mte01
Comment Utility
>> OK I suggest you one rude manual rude operation

what???
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
if you know the jar file name for these classes

com.borland.jbcl.layout.XYLayout;
com.borland.jbcl.layout.XYConstraints;

then u can simply include that jat file  in ur applet code

Hope you understand

0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 380 total points
Comment Utility
for example if the
com.borland.jbcl.layout.XYLayout, com.borland.jbcl.layout.XYConstraints classes are binded with borland.jar

1. then create the jar file as you follows now (Say this may be yourclasses.jar)
2. copy borland.jar and your classes.jar in same directory
3. In ur HTM code u need to do something like this
<applet code=YourApplet.class
      archive="yourclasses.jar ,  borlandr.jar"
      width=460 height=160>
      <param name=foo value="bar">
    </applet>



0
 
LVL 3

Author Comment

by:mte01
Comment Utility
Ahaa okk...I think I understood

>> <param name=foo value="bar">

What is this line for??
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
Nothing to do with that
that is just an example ;-)
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
It worked! Perfect!! But I think that this is a really nasty way to do it. My supervisor is going to kill me when he sees the HTML file of the Applet. Anyway, thank you  sudhakar_koundinya, and everyone who helped me in this
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
great :)
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
Nobody still told me what's a signed applet.....:)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
We need signed applet when we deal with security related operations such as accessing client system's resources
Regards
Sudhakar
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
You can understand abt signed applet by lloing at this article
http://java.sun.com/security/signExample/
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>But I think that this is a really nasty way to do it.

It's actually the proper way to do it ;-) , but sudhakar, i think you mean 'crude' not 'rude' ;-)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
>>but sudhakar, i think you mean 'crude' not 'rude' ;-)

Indians English is quite poor. They understand the language, but when time comes to express their thoughts in English. They fail in it. Hehehehe
0
 
LVL 3

Author Comment

by:mte01
Comment Utility
>> I suggest you one (c)rude manual (c)rude operation

So can I ask what does a manual crude operation then mean??
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Rude used to mean the same as crude but now means obscene or impolite, which could cause some confusion when used of jar files ;-)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now