Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How do I load Java libraries?

How do I load Java libraries?
Thread Tools
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 11, 2004, 08:31 PM
 
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
Reply With Quote
Jul 11, 2004, 09:04 PM
 
Well, according to this: http://developer.apple.com/qa/qa2001/qa1170.html

all I have to do is put them ~/Library/Java/Extensions

Is this the best way?
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Jul 12, 2004, 10:10 AM
 
Originally posted by itistoday:
Well, according to this: http://developer.apple.com/qa/qa2001/qa1170.html

all I have to do is put them ~/Library/Java/Extensions

Is this the best way?
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
Reply With Quote
Jul 12, 2004, 10:37 AM
 
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
Reply With Quote
Jul 12, 2004, 12:06 PM
 
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:02 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2