download and use a package

O

Oliver Wong

Lee said:
Hi, I downloaded this package

http://jakarta.apache.org/site/downloads/downloads_commons-httpclient.cgi

and I don't know how to use it. Specifically, I want to use the
package in an applet on a web page. The download consists of a jar
file, text files, and a doc folder with documentation.

I know it's something simple like putting the file in a directory, but
I don't really know how to do it, especially on this applet.

Thanks for the help!

Applets can introduce some extra complications, so I recommend that you
first try to write an application that uses a JAR file, and get that working
first, and only then move on the applets with external JARs.

To use it in an application, you'd just add the JAR to your classpath.
When your application tries to access classes within the JAR file, the
classloader can do its job as long as the classpath contains your JAR as one
of its entries.

See http://mindprod.com/jgloss/classpath.html

- Oliver
 
L

Lee

Surely there is a simple explanation to this. Can I just put it into a
special directory on the server? Or am I supposed to compile it with
the jar in a particular directory as it's compiled?
 
O

Oliver Wong

[post re-ordered]

Lee said:
Surely there is a simple explanation to this. Can I just put it into a
special directory on the server? Or am I supposed to compile it with
the jar in a particular directory as it's compiled?

Dropping jars in random folders won't suddenly give an applet the
ability to act as an HTTP client if it wasn't already designed to do that.
Did you write the applet? Is your intent you give it the ability to act as
an HTTP client? Did you write some code to make it so?

- Oliver
 
L

Lee

I have an applet that I wrote, and I'd like to import that jar file
somehow and extend the program. It has certain functions in it that
I'd like to use.
Would it be better if I just extracted all the class files from it? I
know that I can just have a class file in a directory for it to be
imported.

Oliver said:
[post re-ordered]

Lee said:
Surely there is a simple explanation to this. Can I just put it into a
special directory on the server? Or am I supposed to compile it with
the jar in a particular directory as it's compiled?

Dropping jars in random folders won't suddenly give an applet the
ability to act as an HTTP client if it wasn't already designed to do that.
Did you write the applet? Is your intent you give it the ability to act as
an HTTP client? Did you write some code to make it so?

- Oliver
 
A

Andrew Thompson

Lee wrote:

( Please refrain from top-posting, Lee it is very confusing. )
I have an applet that I wrote, and I'd like to import that jar file
somehow and extend the program.

The applet element has an 'archive' attribute, it might
look like this..

<applet
code='org.jdesktop.jdic.screensaver.ScreensaverApplet'
archive='api/sb-api-dev.zip,jar/bouncingline.jar'
width=200
height=200
Note that the main applet is in 'sb-api-dev.zip', while that
applet loads other classes from 'bouncingline.jar' (in this
case, they are for a screensaver animation).

If you add the HHTPclient (or whatever jar it is) to the
'archive' attribute of your applet element, then *your* applet
should have access to all the public members of the
HTTPclient jar.
..It has certain functions in it that
I'd like to use.

As long as they are declared 'public', it should be no problem.
Would it be better if I just extracted all the class files from it?

No! That causes more problems than it fixes.

HTH

Andrew T.
 
L

Lee

( Please refrain from top-posting, Lee it is very confusing. )
ah! sorry, my client has a way of hiding the forwarded text below and
makes me forget about it.
<applet
code='org.jdesktop.jdic.screensaver.ScreensaverApplet'
archive='api/sb-api-dev.zip,jar/bouncingline.jar'
width=200
height=200

Would this work then? I'm not sure why you have a zip file in your
archive attribute.
<applet
code='org.apache.commons.httpclient.*'
archive='myapplet.class, httpclient.jar'
width=300
My applet would be myapplet.class, and httpclient.jar would be the jar
file I'm trying to import into my code.
In my code I'd have a statement like this:
import org.apache.commons.httpclient.*;

Thanks!
 
O

Oliver Wong

Lee said:
ah! sorry, my client has a way of hiding the forwarded text below and
makes me forget about it.


Would this work then? I'm not sure why you have a zip file in your
archive attribute.
<applet
code='org.apache.commons.httpclient.*'
archive='myapplet.class, httpclient.jar'
width=300

My applet would be myapplet.class, and httpclient.jar would be the jar
file I'm trying to import into my code.
In my code I'd have a statement like this:
import org.apache.commons.httpclient.*;

I believe the code attribute would be the fully qualified name of your
applet. So my guess is it's something like:

<applet
code="foo.bar.myapplet"
archive="httpclient.jar"
width="200px"
height="200px"
/>

where you'd replace foo.bar with whatever package your applet is in.

- Oliver
 
A

Andrew Thompson

(A.T.)
.....
...I'm not sure why you have a zip file in your archive attribute.

A Jar file is simply a specialist form of Zip file.
Try this, make a copy of a jar file, rename it to .zip
and open it.

(I am presuming that Oliver answered your technical question)

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top