I prototyped a PDF viewer in Intellij Idea and am trying to integrate it into a Netbeans project. I have been unable to get Netbeans to recognize the jar file that contains the classes I use.
Netbeans Version - 15.0.2, JDK version - 15, Windows 10
Here is one of the errors in the code:
From the first line of the following method:
private void initializeFile(File file)
{
PDDocument doc = PDDocument.load(file);
// Getting/calculating screen dimensions...
float realWidth = doc.getPage(0).getMediaBox().getWidth();
float realHeight = doc.getPage(0).getMediaBox().getHeight();
System.out.println("RealW, RealH: " + realWidth + ", " + realHeight);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double ratio = 0.6;
this.height = (int) (screenSize.getHeight() * ratio);
this.width = (int) ((height * realWidth) / realHeight);
this.numberOfPages = doc.getNumberOfPages();
renderer = PDFRenderer(doc);
System.out.println("Number of pages = " + numberOfPages);
}
Alt-Enter on the red underline:
When I select the Search Dependency at Maven Repositories for PDFDocument, I get this:
It finds the jar file I downloaded and put in the src/java/main
directory. When I click on the Add
button, it works for a few seconds and then displays this in the status line:
Finished retrieving dependencies from remote repositories.
But the error remains, it still can't find the class PDDocument.
I tried the following command line which didn't fail but didn't remove the error.
$ mvn install:install-file -Dfile="pdfbox-app-2.0.27.jar" -DgroupId="org.apache.pdfbox" -DartifactId="pdfbox" -Dversion=2.0.27 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:\hg\project\MyName\src\main\pdfbox-app-2.0.27.jar to C:\Users\ME\.m2\repository\org\apache\pdfbox\pdfbox\2.0.27\pdfbox-2.0.27.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.328 s
[INFO] Finished at: 2023-01-31T10:25:05-08:00
[INFO] ------------------------------------------------------------------------
Here is the section of my pom.xml
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.27</version>
<type>jar</type>
</dependency>
I've gone through all of these suggestions to no avail:
https://stackoverflow.com/questions/17693040/adding-external-jar-to-maven-project-in-netbeans
Here is the relevant section of my Project's dependencies:
Is there a log somewhere where I can see what Netbeans did behind the curtain, especially if it encountered an error? What else can I try?
Thanks