File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How to import a Jar correctly ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to import a Jar correctly ?" Watch "How to import a Jar correctly ?" New topic

How to import a Jar correctly ?

choubix alex

Joined: Dec 25, 2009
Posts: 22

I am learning the basics of Swing / Substance look and feel.
I'd like to add some icons to my Jbuttons. (load, save, delete...)

I came across the graphic library (from it comes a Jar file that contains gif files.
I've built a class path for the Jar and it is now in the "reference library" folder.

but when I try to do "import thenameofmyjar.*;" where my code is it returns an error.

basically: I know how to import the jar in my project as a reference but I don't know how to make use of it

can someone tell me how to do please?

by the way: if I download a pack of gif from the web for my interface. how would I link these gif files to my project? (do I need to create a jar file for them? if so: is there a tutorial for that? do I need to put them in a folder and reference them manually?)

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
Find this page, then look up the links for the "java" tool. Go through that link and find the instructions about how to add the .jar to your classpath. You should use the -cp or -classpath options; don't set a system environment variable. You may need to do the same for the "javac" tool.
David Newton

Joined: Sep 29, 2008
Posts: 12617

And you don't import jars, you import classes.
I agree. Here's the link:
subject: How to import a Jar correctly ?
It's not a secret anymore!