Here is my pomfile.xml:
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"> 4.0.0 com.rasweeny Recipes 1.0-SNAPSHOT jar<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>15</maven.compiler.source> <maven.compiler.target>15</maven.compiler.target> <exec.mainClass>com.rasweeny.recipes.Recipes</exec.mainClass> </properties> <dependencies> <dependency> <groupId>com.github.pcorless.icepdf</groupId> <artifactId>icepdf-core</artifactId> <version>7.0.1</version> <type>jar</type> </dependency> <dependency> <groupId>com.github.pcorless.icepdf</groupId> <artifactId>icepdf-viewer</artifactId> <version>7.0.1</version> <type>jar</type> </dependency> </dependencies> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>config/sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> <build> <plugins> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.0</version> <configuration> <archive> <manifest> <mainClass>com.rasweeny.recipes.Launcher</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> <resources> <resource> <directory>[Users/rasweeny/jarfiles/icepdf-7.0.1/]</directory> <includes> <include>[icepdf-core-7.0.1.jar]</include> <include>[icepdf-viewer-7.0.1.jar]</include> <include>[fontbox-2.0.27.jar]</include> <include>[resource file #n]</include> </includes> </resource> </resources> </build> </project>
The imports :
import org.icepdf.ri.common.ComponentKeyBinding; import org.icepdf.ri.common.SwingController; import org.icepdf.ri.common.SwingViewBuilder;
Here is my code :
if (exten.equals("pdf")) { String filePath = file; SwingController controller = new SwingController(); SwingViewBuilder factory = new SwingViewBuilder(controller); SPanel viewerComponentPanel = (SPanel) factory.buildViewerPanel(); ComponentKeyBinding.install(controller, viewerComponentPanel); controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback( controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame(fileName); Dimension pdfSize = new Dimension(640,800); window.setMinimumSize(pdfSize); window.setMaximumSize(pdfSize); window.setPreferredSize(pdfSize); window.add(viewerComponentPanel); window.pack(); window.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width)
/ 2 - 600 / 2, (Toolkit.getDefaultToolkit().getScreenSize().height) / 2 - 800 / 2); window.setVisible(true);
controller.openDocument(filePath);
If I run it in netbeans everything works fine. Once I clean and build it and move the application to a folder on my drive. I get this error.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/icepdf/ri/common/views/Controller at com.rasweeny.recipes.Recipes.lambda$setupGUI$0(Recipes.java:142) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) .....
Line 142 is : window.pack(); I have added icepdf as a dependency to the app in the local repository.
I am using Mac OSX 10.15.7 Catalina, JDK 17, Netbeans 16, and Maven 4.0.0.
What am I missing? Thanks, Rich
Sorry here is the full output:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/icepdf/ri/common/views/Controller at com.rasweeny.recipes.Recipes.lambda$setupGUI$0(Recipes.java:142) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Caused by: java.lang.ClassNotFoundException: org.icepdf.ri.common.views.Controller at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 14 more rasweeny:recipes rasweeny$
Like I said it works fine launching from Netbeans but I get this error when trying to launch it from my hardd rive.