9

I am having trouble setting up the build path of my java project. I am currently in a Co-Op IT position so I am somewhat new to all this. My background is mostly in C++ and I am learning java on the fly. I am also somewhat new to Eclipse (Kepler service release 1).

I am working on a bug on an existing program and need to get the program to build so I can work on it. When I add all of the external .jar files that I know for a fact are the right ones, I am getting this error on two of them :

"Archive for required library: '(location of file)' cannot be read or is not a valid ZIP file"

Two of the other full time guys on my team have gotten the program to run with those exact same .jar files, one running Eclipse Indigo and the other running the same Kepler version as myself. I also was able to open the two .jar files manually and everything appears to be there. After every trial trying to fix this, I have refreshed, cleaned and restarted eclipse. The two other full time guys said they have never seen this error. I would like to get some insight on this from anyone who has any similar experiences so that I don't have to use up much more of their time.

  • 1
    First, verify the jar(s) are good with `jar tvvf FILE`. Then, add them into your eclipse project. Finally, right click and add to "Build Path". – Elliott Frisch Jan 13 '14 at 14:03
  • Tried this, and the .jar files were good. I still got the same error when I re-added them to the build path. –  Jan 13 '14 at 14:36
  • Try starting eclipse from the command line, with "eclipse -clean" - refer to [this question](http://stackoverflow.com/questions/2030064/how-to-run-eclipse-in-clean-mode-and-what-happens-if-we-do-so) for an explanation. – Elliott Frisch Jan 13 '14 at 14:37
  • I started eclipse with "eclipse -clean" from the command line and It didn't change anything. I also tried copying the eclipse folder on my desktop and changing the copy's eclipse.ini to start with -clean. Also didnt work. –  Jan 13 '14 at 14:59
  • You must have included a non-JAR file (.xml or .properties) in the classpath. – Mohamed Ennahdi El Idrissi Nov 21 '15 at 10:21
  • 1
    I'm getting this error with a .properties file. What should I do? – Martin Erlic May 23 '16 at 14:45

10 Answers10

6

I Had this issue, just fixed by deleting .jar files from Libs directory then copy->paste original Jars again. Then do a complete clean -> rebuild

AnhSirk Dasarp
  • 701
  • 2
  • 20
  • 38
3

I got this problem, took help from following link solution which basically says to 1. delete the corresponding maven download folder 2. maven>update project in eclipse

In my case I deleted hibernate folder, since i was getting error related to hibernate-validator.jar

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73
2

I had the same error here. What I did to resolve the problem was close and reopen the project.

Calixto
  • 416
  • 3
  • 7
0

I got the same problem and found out the root cause is the JDK in my linux shell is set to 1.6, but in the eclipse, the JRE is 1.7.

Frank Fu
  • 778
  • 4
  • 8
  • 12
0

Using Eclipse without m2e features (Standard Edition) helped me.

Similar problem with Spring toolsuite

Community
  • 1
  • 1
Basilevs
  • 22,440
  • 15
  • 57
  • 102
0

Just came across this link that shows a way to get unblocked. In preferences dialog box go to

Java->Compiler->Building

and change Incomplete build path to "Warning" (from default "Error") This can be done globally (for all projects), or on a project by project basis.

xbranko
  • 585
  • 5
  • 12
0

Check the jar's file permissions/ownership. I had the same issue on eclipse installed on Linux and fixed it by setting the file permissions right.

user1384205
  • 1,231
  • 3
  • 20
  • 39
0

In my case ..worked after removing this from spirngrest-servlet.xml file.

    <prop key="net.sf.ehcache.configurationResourceName">/Sysehcache.xml</prop>

I think it had to do with default location of maven repository of jar files. Been at it for 3 days. finally solved it.Hope it helps anyone.Just look for similar think in your spirngrest-servlet.xml file. Good luck.

Debasish Ghosh
  • 1,867
  • 20
  • 29
0

I just tried the following and it worked:

Close eclipse as there might be some files eclipse is accessing and you won't be able to delete.

Delete all the libraries installed in the maven repositories folder: ".m2/repository"

Open eclipse and update your project(Alt+F5).

What did we just do? : This is possible that the existing libraries in the local repository are erroneous and maven tries to open which it fails in. We have now deleted the already existing library and with the project update, Maven will download the library again which should resolve the issue.

Nandan Chaturvedi
  • 1,028
  • 3
  • 16
  • 32
0

i fixed this by just deleting everything inside of the /Users/username/.m2/repository folder. not the repository folder itself. and then running a mvn clean package in the project folder