• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using classes from apache: commons-collections-3.2.1

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an application that needs the Multimap from org.apache.commons.collections package.

I went to the apache.org site and found a download with commons-collections-3.2.1

In the README it says it uses Ant as the build tool and there is no build.xml file. Does this mean I have to create the build.xml file myself ?

All i want to do is get the .class files put them in an appropriate folder-structure as usual for java packages and then add the containing folder to my classpath.

Would it be crazy to get the .java files and compile from source and create the appropriate folder structure and adding to the classpath ?
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Depends how many .java files you have. If you have a manageable number try putting your org folder cataining apache containing commons containing collections inside your folder structure in the appropriate location. You can do that by putting the jar file in your folder structure and unzipping it. I can't remember exactly where you put it, so try moving the org folder with drag-and-drop in your directory explorer until it works.
 
Tim McMurry
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the welcome and the assistance .

Oh my, quite emberassing I had tried to "unpack" the jar-file by issuing "java -jar target.jar" which of course gave a no-menifest message :-)
Unzipping it takes care of everything as the appropriate folder-tree is already created. I think I will give myself a 2-week ban from posting questions about Java for this one !
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim McMurry wrote:Oh my, quite emberassing I had tried to "unpack" the jar-file by issuing "java -jar target.jar" which of course gave a no-menifest message :-)
Unzipping it takes care of everything as the appropriate folder-tree is already created. I think I will give myself a 2-week ban from posting questions about Java for this one !



You can "unpack" the jar file with the jar command -- "jar xvf target.jar".... but.... why are you doing this? what's wrong with just putting the whole jar file into the classpath. I don't believe these packages were meant to be used in pieces like this.

Henry
 
Tim McMurry
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,

I thought that if I only include the .jar-file in my classpath and dont actually have .class-files unpacked in the appropriate structure then I wouldnt be able
use the classes through import statements in my code ?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim McMurry wrote:I thought that if I only include the .jar-file in my classpath and dont actually have .class-files unpacked in the appropriate structure then I wouldnt be able
use the classes through import statements in my code ?



The Java compiler can find class files located inside Jar files. If the jar file is in the classpath, the compiler will search the jar file during compilation. This is also true of the JVM during runtime.

Henry
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You normally don't need to unpack JAR files to use them. Just put the JAR file in the classpath, and Java will be able to use the classes inside the JAR. You don't need to unpack the JAR to be able to import the classes in your source code.

You also don't need to get the source code and compile it yourself if you just want to use the classes.
 
Tim McMurry
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanations. Ill go read up on the JAR file format :-)

I had tried adding the JAR file to my classpath, but the compiler complained about it not finding the package, thats why I assumed the actual class -files needed to be there. So I must have made a mistake when setting the classpath firstly trying to use the jar.

Things work now. Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic