Libaray Settings in JAR files

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.

LVL 3
mte01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
CEHJCommented:
>>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
 
mte01Author Commented:
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
 
CEHJCommented:
>>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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mte01Author Commented:
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
 
doronbCommented:
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
 
mte01Author Commented:
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
 
doronbCommented:
I think that JBuilder can't correctly discover the correct dependency tree for your applet.

Is your applet a signed applet?
0
 
mte01Author Commented:
I've heard of signed software, but signed applets???
0
 
sudhakar_koundinyaCommented:
>>Is your applet a signed applet?
I think this problem may not be related with signed applet
0
 
sudhakar_koundinyaCommented:
mte01

Actually what dependency classes u need to include in your jar file??
0
 
mte01Author Commented:
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
 
sudhakar_koundinyaCommented:
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
 
mte01Author Commented:
>> OK I suggest you one rude manual rude operation

what???
0
 
sudhakar_koundinyaCommented:
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
 
sudhakar_koundinyaCommented:
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
mte01Author Commented:
Ahaa okk...I think I understood

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

What is this line for??
0
 
sudhakar_koundinyaCommented:
Nothing to do with that
that is just an example ;-)
0
 
mte01Author Commented:
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
 
sudhakar_koundinyaCommented:
great :)
0
 
mte01Author Commented:
Nobody still told me what's a signed applet.....:)
0
 
sudhakar_koundinyaCommented:
We need signed applet when we deal with security related operations such as accessing client system's resources
Regards
Sudhakar
0
 
sudhakar_koundinyaCommented:
You can understand abt signed applet by lloing at this article
http://java.sun.com/security/signExample/
0
 
CEHJCommented:
>>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
 
sudhakar_koundinyaCommented:
>>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
 
mte01Author Commented:
>> I suggest you one (c)rude manual (c)rude operation

So can I ask what does a manual crude operation then mean??
0
 
CEHJCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.