Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

download and use a package

Thread view: 
Lee - 11 Jul 2006 19:26 GMT
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!
Oliver Wong - 11 Jul 2006 21:09 GMT
> Hi, I downloaded this package
>
[quoted text clipped - 8 lines]
>
> 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
Lee - 14 Jul 2006 03:11 GMT
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?

> > Hi, I downloaded this package
> >
[quoted text clipped - 21 lines]
>
>     - Oliver
Oliver Wong - 14 Jul 2006 15:05 GMT
[post re-ordered]

>> > Hi, I downloaded this package
>> >
[quoted text clipped - 27 lines]
> 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
Lee - 14 Jul 2006 21:51 GMT
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.

> [post re-ordered]
>
[quoted text clipped - 36 lines]
>
>     - Oliver
Andrew Thompson - 14 Jul 2006 22:04 GMT
( 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.
Lee - 16 Jul 2006 18:33 GMT
> ( 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!
Oliver Wong - 18 Jul 2006 14:52 GMT
>> ( Please refrain from top-posting, Lee it is very confusing. )
> ah!  sorry, my client has a way of hiding the forwarded text below and
[quoted text clipped - 18 lines]
> 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
Andrew Thompson - 18 Jul 2006 16:28 GMT
(A.T.)
> > <applet
> >   code='org.jdesktop.jdic.screensaver.ScreensaverApplet'
> >   archive='api/sb-api-dev.zip,jar/bouncingline.jar'
....
> ...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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.