aspose file tools*
The moose likes Java in General and the fly likes import jar in eclipse // Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "import jar in eclipse //" Watch "import jar in eclipse //" New topic
Author

import jar in eclipse //

nor alain
Greenhorn

Joined: Mar 19, 2009
Posts: 11

Dear all,

I want to ask about the import in eclipse ...

The teacher sent a jar file to use it as a component when we do our assignment ...

i try to import the jar and use it in the java project, but it doesn't work ..

when i import the jar file, i do the following: import >> archieve file ...>> it is the right way to import jar file ?

can someone tell me how to import the jar and use it in the java project ?

[NK: Removed font color]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
Welcome to JavaRanch

Please don't write all in red; it is difficult to read.
This would sit better on the IDEs forum. Nitesh will probably move it.

R-click the name of the project on the left pane-> properties->Java Build Path->libraries tab->add external jars->find the jar->OK->OK->OK.
nor alain
Greenhorn

Joined: Mar 19, 2009
Posts: 11
Sorry for the red color ...

mm ok.. i do this step ..
but how can i use the jar on the code ?

for example, when we want to import a libaray in java, we write " import java.awt.* " as example. ..
Fred Grott
Ranch Hand

Joined: Oct 05, 2002
Posts: 346

obviously you put in a libs folder in the project for your ant support..

Now once that is done right click your project folder in eclipse

The menu item you want to click on is called buld path
and the sub selection you want is libraries

than choose user libraries and set one up for that jar you just imported




nor alain wrote:Sorry for the red color ...

mm ok.. i do this step ..
but how can i use the jar on the code ?

for example, when we want to import a libaray in java, we write " import java.awt.* " as example. ..


MobileBytes blog - Sharing Technology - My Programming Knols
nor alain
Greenhorn

Joined: Mar 19, 2009
Posts: 11
the import is successful now ..

import SWEB401_HW1.NumericOperation;



but i can't use the methods in the class ( which is in the jar) ..

For example, the class NumericOperation has a method which is add ;
when i tried to create object for the class to call the method, the program give me error because the constructor of the class is not visible ..

what can i do ?

Nandan Jain
Ranch Hand

Joined: Feb 14, 2006
Posts: 44
I believe that add method is static which means you should not create of the class i order to call its method.
Try doing this:
ClassName.methodName();

like in your case do:
NumericOperation.add();

Thanks
nor alain
Greenhorn

Joined: Mar 19, 2009
Posts: 11
I ready do this step, but it give me a syntax error ..

it give me this message ;;
"Syntax error on token "add", Identifier expected after this token";
nor alain
Greenhorn

Joined: Mar 19, 2009
Posts: 11
I tried several things to use the methods which are in the class ( in the jar ) ...

first, i tried to create an instance, but it doesn't work because the constructor is not visible ...
second, i tried to use the class as abstract class and extend it on the new class .. but also it give me the same error ( constructor is not visible ) ..

I don't know what can i do to use the class's methods !!
 
 
subject: import jar in eclipse //