Solved

Libaray Settings in JAR files

Posted on 2004-09-08
26
504 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 10
  • 4
  • +1
26 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12010337
>>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
ID: 12010575
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
ID: 12010622
>>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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:mte01
ID: 12010661
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
ID: 12011177
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
ID: 12011237
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
ID: 12011259
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
ID: 12011271
I've heard of signed software, but signed applets???
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12011286
>>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
ID: 12011292
mte01

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

Author Comment

by:mte01
ID: 12011321
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
ID: 12011356
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
ID: 12011382
>> OK I suggest you one rude manual rude operation

what???
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12011398
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
ID: 12011421
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
ID: 12011423
Ahaa okk...I think I understood

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

What is this line for??
0
 
LVL 14

Expert Comment

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

Author Comment

by:mte01
ID: 12011495
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
ID: 12011502
great :)
0
 
LVL 3

Author Comment

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

Expert Comment

by:sudhakar_koundinya
ID: 12011514
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
ID: 12011529
You can understand abt signed applet by lloing at this article
http://java.sun.com/security/signExample/
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12011557
>>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
ID: 12011597
>>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
ID: 12011610
>> 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
ID: 12011694
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

617 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