 |
 |
How do I load Java libraries?
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
I know that if a library is in my current CLASSPATH then I can load it with an import statement...
But say I downloaded a library that is a .jar file. I have its documentation so I know what to import, but how can I tell the compiler where the library is? Is there any way I can make it available "system-wide"? What's the best way for dealing with libraries?
Thanks.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
That's the recommended way for end-user usage (JDBC drivers, for instance). If you plan on redistributing the library, you'd typically unroll it and include it in your jar, or if it's a web app, put it in WEB-INF/lib inside your war file.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Originally posted by Arkham_c:
That's the recommended way for end-user usage (JDBC drivers, for instance). If you plan on redistributing the library, you'd typically unroll it and include it in your jar, or if it's a web app, put it in WEB-INF/lib inside your war file.
So since I'm relatively new to Java programming, and I do want to redistribute an app I'll be developing, how should I "unroll" it and include it in the jar file?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by itistoday:
So since I'm relatively new to Java programming, and I do want to redistribute an app I'll be developing, how should I "unroll" it and include it in the jar file?
You don't need to do so to do your development, but jar files are just zip archives. To unroll it, just do:
Code:
jar -xf somefile.jar
To create a jar file, do:
Code:
jar -cf somefile.jar [source files or folders]
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|