EglCode
EglCode

Reputation: 149

Creating a Java Library or class or package with Jar files

I have about 100 jar files and I think I want to make a library with them. What is the best way to do this? How does importing work with this. Do I still have to ask for each class or do I just refer to the new library?

More detail

I have the GeoTools9.4 package (in a zip). It has about 100 jar files. When I import these into my project in eclipse, it takes each jar file and stuffs it in and clutters up my structure. So I think I want a library (or a package or a class) I am not sure what the terminology is here.

More detail on how to call the classes in the new library. Right now here is how I call the classes

import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;

If I put all of these jar files in a library can I replace the above lines with a new import like

import org.geotools.local

or do I not need to change the way they are called?

Upvotes: 1

Views: 158

Answers (2)

Mysterion
Mysterion

Reputation: 9320

I propose you to use a Maven for this stuff.

Maven is a greay build tool, that could take care of problems, like adding dependency jars to a project. Also, GeoTools support Maven and have a nice manual for it (http://docs.geotools.org/latest/userguide/tutorial/quickstart/maven.html)

About last question - when you'll add this libraries, full name of these classes will be the same, so you must import and use them as you import them right now.

Upvotes: 4

c.s.
c.s.

Reputation: 4816

This is not usually refered to as "calling" the classes, but rather importing the classes meaning that they become available to the class that uses them.

No matter how you have those classes (in many jars or a single jar) you still need to have the import statements in the beggining of the class file for the source to be compiled

I am not sure how Eclipse "clutters up" your structure. You can place all the jars in a single folder e.g. lib and then import them into your eclipse project from that folder. If you mean that the jars show up in the left pane then there are filters that can hide them. In Eclipse there is the concept of a Working set where you can select what it would be visible and what not.

I hope it helps

Upvotes: 2

Related Questions