Я использую зависимость org.jdesktop.application и хочу загрузить некоторые ресурсы. Gradle-проект структурирован в:
- main.java.myproject
- main.resources
Когда я хочу загрузить карту ресурсов, используя getResourceMap()
. Он не читает никаких свойств, поэтому я думаю, что эти файлы должны храниться в main.java.myproject.resources
. Как задать путь к карте ресурсов, чтобы сохранить структуру моего проекта?
Пример кода:
public MyView(SingleFrameApplication app) {
super(app);
initComponents();
ResourceMap resourceMap = getResourceMap();
resourceMap.getInteger("timeout"); // <-- NullPointerException
}
Stacktrace:
Oct 19, 2019 4:00:01 PM org.jdesktop.application.Application$1 run
SEVERE: Application class myproject.MyApp failed to launch
java.lang.NullPointerException
at myproject.MyView.<init>(MyView.java:156)
at myproject.MyApp.startup(MyApp.java:30)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
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(Native Method)
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)
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class myproject.MyApp failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
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(Native Method)
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.NullPointerException
Caused by: java.lang.NullPointerException
at myproject.MyView.<init>(MyView.java:156)
at myproject.MyApp.startup(MyApp.java:30)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 13 more