Reputation: 729
I've written a Swing application that uses a JavaFX component and I'd like to package it for distribution, however I haven't been able to figure it out.
In Intellij Idea I selected File-> Project Structure-> artifacts and chose "from module". Next I selected Build-> Generate Ant Build and generated some Ant files. I modified the is line:
<fx:application id="JReader_id" name="JReader" mainClass="com.facetoe.jreader.JReader"/>
as described here to:
<fx:application id="JReader_id" name="JReader" mainClass="com.facetoe.jreader.JReader" toolkit="swing"/>
to indicate its a Swing application. Finally I built the .jar
using Build-> Build Artifacts in Intellij and the .jar was created without errors. However when I attempt to run the .jar I get this error:
⇒ java -jar out/artifacts/JReader/JReader.jar
java.lang.IllegalAccessException: Class com.javafx.main.Main can not access a member of class com.facetoe.jreader.JReader with modifiers "public static"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
at java.lang.reflect.Method.invoke(Method.java:599)
at com.javafx.main.Main.launchApp(Main.java:714)
at com.javafx.main.Main.main(Main.java:871)
It looks like it cannot run the main method for some reason... Does anyone have any idea how I could fix this?
Upvotes: 2
Views: 230
Reputation: 729
Ok I figured it out. The class containing my method was not public
, so I made it public
and everything works fine now.
Upvotes: 1