Unable to add jsch-0.1.55.jar to existing Eclipse java project

40 Views Asked by At

I downloaded jsch-0.1.55.jar from https://sourceforge.net/projects/jsch/files/jsch.jar/0.1.55/jsch-0.1.55.jar/download, copied the JAR file into my lib directory, running Eclipse Version: 2023-12 (4.30.0) on Windows. I attempted to add the JAR to the Eclipse by using Project Explorer->Right mouse click on project->Build Path->Configure Build Path->Java Build Path->Libraries Tab->Modulepath->Add JARs...->went to the lib folder I copied the JAR file to, but it's now showing, double checked it's in the lib folder via Windows Explorer and it is. Tried adding it via Modulepath->"Add External JARs...", which it does add but it never shows up in Project Explorer under the lib folder, though it does show in Referenced Libraries, but when I try to do an import within the class I need it "import com.jcraft.jsch.*;", I get the error, "The package com.jcraft.jsch is not accessible". I tried adding it to my module-info.java file "requires com.jcraft.jsch;", but I get the error, "com.jcraft.jsch cannot be resolved to a module".

Any help would be appreciated and no, I'm not using maven on this project.

1

There are 1 best solutions below

5
howlger On BEST ANSWER

jsch-0.1.55.jar has neither a module-info.class nor an Automatic-Module-Name in its META-INF/MANIFEST.MF. So the module name will be derived from the file name of the JAR.

In your module-info.java file, replace

requires com.jcraft.jsch;

with

requires jcraft;

Alternatively, you can delete your module-info.java file (if needed you can recreate it later via right-click on the project and choosing Configure).