0

I cloned this project from GitHub in Eclipse (requires Maven to set up quickly). I may or may not tweak it, but I want to export it into a JAR file. https://github.com/eugener/oxbow

When I run the test main method in in src/test/java/org/oxbow/swingbits/dialog/table/filter/TableFilterTest.java it runs fine.

But when I export the project into a JAR file and use it on my own JTables, I get a null pointer exception. It apparently lost track of the image icons and cannot import them.

java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at org.oxbow.swingbits.table.filter.TableFilterColumnPopup.buildContent(TableFilterColumnPopup.java:173)
at org.oxbow.swingbits.popup.PopupWindow$1.popupMenuWillBecomeVisible(PopupWindow.java:67)
at javax.swing.JPopupMenu.firePopupMenuWillBecomeVisible(Unknown Source)
at javax.swing.JPopupMenu.setVisible(Unknown Source)
at javax.swing.JPopupMenu.show(Unknown Source)
at org.oxbow.swingbits.popup.PopupWindow.show(PopupWindow.java:110)
at org.oxbow.swingbits.table.filter.TableFilterColumnPopup.showFilterPopup(TableFilterColumnPopup.java:278)
at org.oxbow.swingbits.table.filter.TableFilterColumnPopup.mouseReleased(TableFilterColumnPopup.java:237)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)

I don't know much about Maven other than it organizes a project's setup. Can someone please tell me if I'm missing a step?

tmn
  • 11,121
  • 15
  • 56
  • 112
  • I keep trying to manipulate the path of the icon and using getClassLoader() but nothing is working. – tmn Jul 29 '14 at 19:55
  • Do you expect us to swim through your entire project to look for a couple lines of code. Just show the code where you load the image and tell us the file structure up to where the image is. – Paul Samsotha Jul 29 '14 at 23:44
  • Fair enough. I thought the error and stack trace would point to the location, and its not a big project, but I'll highlight it. A colleague found the solution anyway and I will post it momentarily. – tmn Jul 30 '14 at 00:40

1 Answers1

0

I figured out the issue, although it did require modifying the code. The resource path had to be absolute in the context of a JAR file

new ImageIcon(getClass().getResource("/resources/org/oxbow/swingbits/table/filter/funnel_delete.png")))

instead of

new ImageIcon(getClass().getResource("funnel_delete.png")))
tmn
  • 11,121
  • 15
  • 56
  • 112