Eclipse can't find Maven dependency package

Eclipse can't find Maven dependency package



In Eclipse, I created a project using Maven and added pdfbox as a dependency. Eclipse automatically rebuilt the project, and I see pdfbox-2.0.11.jar in Maven Dependencies in the package explorer.



However, in my main Java file where I intend to use this:


package my.group.project;
import org.apache.pdfbox.pdmodel.PDDocument;



Eclipse tells me "The import org cannot be resolved."



What do I do?



My pom.xml:


pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>my.group</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>invoices</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.11</version>
</dependency>
</dependencies>
</project>






Are you using the latest jdk10? (10.0.2) If you have jdk 1.8 installed, can you try with that one?

– Tilman Hausherr
Sep 17 '18 at 9:16






And what maven version are you using?

– Tilman Hausherr
Sep 17 '18 at 9:17






Java SE 10, not sure how to check maven version

– OldBunny2800
Sep 17 '18 at 11:43






There are several Java SE 10 versions, it could be 10, 10.0.1, or 10.0.2. Run "java -version" on the command. To get the maven version, find the maven directory and then enter "mvn -version" there. This will also tell you the java version.

– Tilman Hausherr
Sep 17 '18 at 11:51






Thanks, java: 10.0.2, maven: 10.0.2

– OldBunny2800
Sep 17 '18 at 12:17




3 Answers
3



Just for clarification: I guess that the particular class is also visible if you extend the contents in the jar in the package browser, isn't it?



If that's the case could you maybe provide your pom.xml?



However, you could also try to clean the project via Project -> Clean first.. Eclipse sometimes just behaves weird as you certainly know.


Project -> Clean






1. Yes it is. 2. sure! 3. Thanks, I’ll try that.

– OldBunny2800
Sep 16 '18 at 15:05






Cleaning didn't help, and I edited in the pom.xml. Welcome to SO, by the way!

– OldBunny2800
Sep 16 '18 at 15:11






Thanks. ;) So, I built a test project myself using your pom.xml that also imports the PDDocument and for me it worked perfectly fine. Does eclipse point out any build path problems? And which JRE version are you using?

– lema
Sep 17 '18 at 7:54







If nothing of this works you could try to build a new Maven project by importing your pom.xml using the Maven import wizard. That's what I did. After that you could then move your sources from the old to the new project and it should work. Something seems to be corrupted in your project setup.

– lema
Sep 17 '18 at 8:02






No build path problems as far as I can tell, Java SE 10.0.2, deleting project from workspace and importing as Maven project didn't change anything.

– OldBunny2800
Sep 17 '18 at 13:44



This might help:



Project --> Properties --> Maven.
Uncheck the box labeled "Resolve dependencies from Workspace projects" --> Apply and Close



Right click on your project --> Maven --> Update Project...
Check the boxes "Force Update of Snapshots/Releases", "Update project configuration from pom.xml", "Clean projects"






Thanks, but it didn't help.

– OldBunny2800
Sep 16 '18 at 15:41



There was something terribly wrong with my project, so I created a new one, added pdfbox as a Maven dependency, copied the Java file over, and everything worked fine.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ