JavaFX - IntelliJ plugin development.

Hello,
I'm writting some simple IntelliJ plugin using Java8 and JavaFX. Unfortunately I have to add jxrt.jar library in project settings otherwise I'm getting a lot of exceptions connected with not finding javafx definitions. For example:
"
[   7541]  ERROR - ctionSystem.DefaultActionGroup - javafx/scene/Parent
java.lang.NoClassDefFoundError: javafx/scene/Parent
    at java.lang.Class.forName0(Native Method)
.....
"

Adding this library is not problematic if I'm using my plugin in IntelliJ or Android Studio on the same OS (in my case Ubuntu 12.04). Unfortunately using this plugin on other system (example creating on Ubuntu and using on Windows) generates following nullpointer exceptio:
"
null
java.lang.NullPointerException
    at com.sun.glass.ui.Application.run(Application.java:145)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:279)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:216)
    at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:198)
    at javafx.embed.swing.JFXPanel.<init>(JFXPanel.java:215)
    at com.xxx.MonitorWindow.showWindow(MonitorWindow.java:78)
    at com.xxx.SoundIntensityMonitor.actionPerformed(SoundIntensityMonitor.java:12)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:164)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:266)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:926)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:236)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:105)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:512)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:44)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:532)
    at java.awt.Component.processMouseEvent(Component.java:6525)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6290)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
...
"

Could you explain me what is the reason of it ? (jxrt.jar not portable ?) Is it possible to build plugin with JavaFX but without including JavaFX jars ? Is there any solution for it in IntelliJ ?

I've read few discussions about similar problems here, but I couldn't find the answer.  (eg: https://devnet.jetbrains.com/message/5533550). I'll be appreciate for any answer.

Thank you.

ps 1.
Just for notification, when I'm creating simple project (not plugin) in IntelliJ which is using JavaFX, there are no problems with portability and there is no jxrt.jar included in output application.
ps 2.
On both OSes I've got IntelliJ 14 CE and Java 8.

4 comments
Comment actions Permalink

You mustn't include jfxrt.jar with your plugin; it's part of the JDK runtime library. To have everything work during development, you need to add the jar to the classpath of your IntelliJ IDEA SDK, not as a separate project library.

Note that IntelliJ IDEA on Mac OS X runs under JDK 6 by default, which does not include any JavaFX support. If you want to publish your plugin developed using JavaFX, it will be unavailable for a large portion of the IntelliJ IDEA user base.

0
Comment actions Permalink

Thanks for reply.

I had jfxrt.jar in the classpath of Intellij Idea SDK. It was added automatically during JDK configuration. Below is how it looks like:

"
jar:///usr/lib/jvm/java-8-oracle/jre/lib/plugin.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/javaws.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/jce.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/management-agent.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/rt.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/jfxswt.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/resources.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/deploy.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/sunec.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/sunpkcs11.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/zipfs.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/localedata.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/nashorn.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar!/
jar:///usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar!/
jar:///home/piotr/ProgrammingTools/IntelliJ/idea-IC-139.1117.1/lib/idea_rt.jar!/
jar:///home/piotr/ProgrammingTools/IntelliJ/idea-IC-139.1117.1/lib/serviceMessages.jar!/
jar:///home/piotr/ProgrammingTools/IntelliJ/idea-IC-139.1117.1/lib/optimizedFileManager.jar!/
jar:///home/piotr/ProgrammingTools/IntelliJ/idea-IC-139.1117.1/lib/jna-utils.jar!/
jar:///home/piotr/ProgrammingTools/IntelliJ/idea-IC-139.1117.1/lib/proxy-vole_20120920.jar!/
...............
"


After removing jfxrt.jar from Libraries I can prepare plugin for deployment (it's being generated *.jar file). But project in general is not working. When I'm running it I'm getting below exception:
"
[   7365]  ERROR - ctionSystem.DefaultActionGroup - javafx/scene/Parent
java.lang.NoClassDefFoundError: javafx/scene/Parent
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:340)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:151)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convert(ActionManagerImpl.java:531)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getActionImpl(ActionManagerImpl.java:511)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:488)
    at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:354)
    at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:312)
    at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:125)
    at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:86)
    at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:280)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.fillMenu(ActionMenu.java:281)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.access$400(ActionMenu.java:41)
    at com.intellij.openapi.actionSystem.impl.ActionMenu$MenuListenerImpl.menuSelected(ActionMenu.java:235)
    at javax.swing.JMenu.fireMenuSelected(JMenu.java:1037)
    at javax.swing.JMenu$MenuChangeListener.stateChanged(JMenu.java:1117)
    at javax.swing.DefaultButtonModel.fireStateChanged(DefaultButtonModel.java:349)
    at javax.swing.DefaultButtonModel.setSelected(DefaultButtonModel.java:232)
    at javax.swing.JMenu.setSelected(JMenu.java:305)
    at javax.swing.JMenu.menuSelectionChanged(JMenu.java:1186)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.menuSelectionChanged(ActionMenu.java:209)
    at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:118)
    at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(BasicMenuUI.java:450)
    at java.awt.Component.processMouseEvent(Component.java:6524)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6292)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4883)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4705)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4530)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2739)
    at java.awt.Component.dispatchEvent(Component.java:4705)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:719)
    at java.awt.EventQueue$4.run(EventQueue.java:717)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:573)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: javafx.scene.Parent PluginClassLoader[com.samsung.unique.plugin.id, 1.0]
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 57 more
[   7369]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.0.3  Build #IC-139.1117.1
[   7369]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.8.0
[   7369]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) 64-Bit Server VM
[   7369]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation
[   7370]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux
[   7370]  ERROR - ctionSystem.DefaultActionGroup - Last Action:  
[   7370]  ERROR - ctionSystem.DefaultActionGroup - Can't unstub Text Boxes (A test menu item)
java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)
    at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:314)
    at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:125)
    at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:86)
    at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:280)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.fillMenu(ActionMenu.java:281)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.access$400(ActionMenu.java:41)
    at com.intellij.openapi.actionSystem.impl.ActionMenu$MenuListenerImpl.menuSelected(ActionMenu.java:235)
    at javax.swing.JMenu.fireMenuSelected(JMenu.java:1037)
    at javax.swing.JMenu$MenuChangeListener.stateChanged(JMenu.java:1117)
    at javax.swing.DefaultButtonModel.fireStateChanged(DefaultButtonModel.java:349)
    at javax.swing.DefaultButtonModel.setSelected(DefaultButtonModel.java:232)
    at javax.swing.JMenu.setSelected(JMenu.java:305)
    at javax.swing.JMenu.menuSelectionChanged(JMenu.java:1186)
    at com.intellij.openapi.actionSystem.impl.ActionMenu.menuSelectionChanged(ActionMenu.java:209)
    at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:118)
    at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(BasicMenuUI.java:450)
    at java.awt.Component.processMouseEvent(Component.java:6524)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6292)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4883)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4705)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4530)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2739)
    at java.awt.Component.dispatchEvent(Component.java:4705)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:719)
    at java.awt.EventQueue$4.run(EventQueue.java:717)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:573)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
[   7370]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.0.3  Build #IC-139.1117.1
[   7370]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.8.0
[   7370]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) 64-Bit Server VM
[   7370]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation
[   7370]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux
[   7370]  ERROR - ctionSystem.DefaultActionGroup - Last Action:  
[  12862]   WARN - api.vfs.impl.local.FileWatcher - Watcher terminated with exit code 0

"

In case when I've got jfxrt.jar in Libraries, plugin is running correctly, but I cannot prepare it for deployment (first post in this discussion)

0
Comment actions Permalink

Do you have any statistics on how big the portion is?
Thanks.

0
Comment actions Permalink

In new 14.1 EAP version, it works (no need to add jfxrt.jar to libraries) both on Linux and Windows.

0

Please sign in to leave a comment.