Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using jars

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
I have been provided with a jar file that has methods that I need to use. I extracted the jar file to my c: and found
the following directory structure:
c:/com/methods/lawsec/

and a whole bunch of classes.

So naturally I have an import statement in my java code:

import com.methods.lawsec.*


to compile I have:
Code:
javac -classpath /path/to/jar/my.jar myTest.java

but I get error:
Code:
myTest.java:3: package com.methods.lawsec does not exist
import com.lawson.lawsec.*;
^

What is the correct import statement so I can use the methods in the jar file? I have not received any documentation from the vendor on this API.

Thanks

 
As the error states, a class is not a package.
You don't need to, in fact, cannot import a class, only a package.

Assuming your classpath (to the JAR file) is correct, you should be able to compile ok if you just lose the import statement.

_________________
Bob Rashkin
 
I don't understand Bong.

If you like to use the extracted classes, use:
Code:
javac -classpath /path/to/jar/my.jar;C:\\ myTest.java
[code]
Better approach: use the foreign jar:
[code]
javac -classpath /path/to/jar/my.jar;/path/to/jar/foreign.jar myTest.java
[code]

I'm not sure, whether forward-slashes work on Windows.
Maybe you need to fix that too.

don't visit my homepage: [URL unfurl="true"]http://home.arcor.de/hirnstrom/bewerbung[/URL]
 
Bong: You can import a class. Actually, I don't use to import whole packages because it's more difficult to keep track of what you're actually using.

After that, you're importing com.methods and compiler is yelling at com.lawson ...

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top