Eclipse, Java: How to import a library in zip-form

2020-05-07 18:11发布

问题:

Ok, this is basic, but it seems that the normal way of doing this doesn't work for me.

I'm trying to import the jSSC library, for communication with serial ports etc. The newest library is jSSC-0.9.0-Release

So, I've tried the following:

  • Placed the zip file in the workspace and added it as "external jar" in the project properties -> java build path -> libraries.

Then I try including something from the library:

import jssc.SerialPortList;

Error: The import jssc cannot be resolved

  • Then I placed the zip file in a folder called /libs in the project root, and added it as "jar" (not external).

Result: Same error.

What basic info/action am I missing here, for this simple operation of importing a library?

回答1:

Are you sure you should include the zip directly? In most releases, the zip contain a jar + readme + some documentation. I think you should take a look at the content of this zip file, perhaps extract it and only include the jar in your project.



回答2:

I believe that your zip file contains a lot of files including jar file with all classes you need, documentation etc. So, extract zip file, find jar you have to add to your eclipse project and do that.

The zip probably contains readme instructions. Read them. This will probably help you to install and use the library.