Hybrid jars [message #1233862] |
Mon, 20 January 2014 12:29  |
Eclipse User |
|
|
|
Hey,
i have a project that has swing + javafx in it. exporting a regular jar obviously doesn't work,
so I build a jar like in the first tutorial.
the jar is created and the build is successful, however i cannot run it :
(running with java -jar)
Exception in Application constructor
2014-01-20 18:44:54.536 java[43988:2707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.javafx.main.Main.launchApp(Main.java:698)
at com.javafx.main.Main.main(Main.java:871)
Caused by: java.lang.RuntimeException: Unable to construct Application instance: class application.Dstrux
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:393)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:276)
... 3 more
Caused by: java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.MenuComponent.<init>(MenuComponent.java:159)
at java.awt.MenuItem.<init>(MenuItem.java:214)
at java.awt.MenuItem.<init>(MenuItem.java:198)
at java.awt.CheckboxMenuItem.<init>(CheckboxMenuItem.java:139)
at java.awt.CheckboxMenuItem.<init>(CheckboxMenuItem.java:122)
at application.Dstrux.<init>(Unknown Source)
... 8 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.javafx.main.Main$2.run(Main.java:948)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1759)
at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1834)
at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1697)
at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:667)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:638)
Also, it weight only 300k, the regular jar was 14m, does that make sense?
Thanks
Lior
|
|
|
|
Re: Hybrid jars [message #1234094 is a reply to message #1234085] |
Tue, 21 January 2014 03:18   |
Eclipse User |
|
|
|
Hey Tom,
Thank you for the reply,
first i have changed the "Toolkit Type" == swing. it did not helped. the jar is still 300k, and i still get the
Process manager already initialized: can't fully enable headless mode.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
for you second question, I'm not repackaging libs, I am exporting all the java sources and resources, than compress the jar.
exception when running. from Jar, when running from the e(fx)clipse all is still ok.
i wrote a new project just so i can find the issue since my project is very large,
i rewrote just the basics, something like a simple javafx project with a system tray app.
again, works well on the e(fx)clipse, but not as jar (except I don't get an error, the jar just doesn't do anything).
As I said before, my app is really big, and working well from the eclipse, so there must be something i'm doing wrong while packaging right?
I would hate to re do this whole thing just cause i cant get a proper jar
ill appreciate any idea at this moment!!!
Thanks!
|
|
|
|
Re: Hybrid jars [message #1234102 is a reply to message #1234094] |
Tue, 21 January 2014 03:38   |
Eclipse User |
|
|
|
Hi,
IIRC the export is not packaging the libraries directly into the JAR but
adds a MANIFEST.MF-Entry pointing to them, not?
I'd need something to test to see what's broken. In the end all our
build is doing is to write the build.xml and execute it. You can take a
look at the build.xml and fix things manually?
Tom
On 21.01.14 09:18, Lior Giller wrote:
> Hey Tom,
>
>
> Thank you for the reply,
>
> first i have changed the "Toolkit Type" == swing. it did not helped. the
> jar is still 300k, and i still get the Process manager already
> initialized: can't fully enable headless mode.
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> for you second question, I'm not repackaging libs, I am exporting all
> the java sources and resources, than compress the jar.
> exception when running. from Jar, when running from the e(fx)clipse all
> is still ok.
> i wrote a new project just so i can find the issue since my project is
> very large, i rewrote just the basics, something like a simple javafx
> project with a system tray app. again, works well on the e(fx)clipse,
> but not as jar (except I don't get an error, the jar just doesn't do
> anything).
>
>
> As I said before, my app is really big, and working well from the
> eclipse, so there must be something i'm doing wrong while packaging right?
> I would hate to re do this whole thing just cause i cant get a proper
> jar :(
> ill appreciate any idea at this moment!!!
>
> Thanks!
|
|
|
|
|
|
|
Re: Hybrid jars [message #1234173 is a reply to message #1234129] |
Tue, 21 January 2014 06:54   |
Eclipse User |
|
|
|
I have some progress which might help understand the issue better.
i realised (and maybe it was obvious but i missed it( that fro running from e(fx)clipse, i use "main" method., but if i want my jar to work, i need to use "start" method.
i manages to get my simple system tray app working by copying my "main" code into the start, but from eclipse its stopped cause i have to have main.
thats why i fail running as javafx jars, as it searches for the start method.
also, on my mac, when i'm running from main all is ok, but same code running from start i get different result for
if (!SystemTray.isSupported()) {
System.out.println("SystemTray is not supported");
return;
running from eclipse- its supported, running from jar its not.
Does that make any sense to you?
Lior
|
|
|
Re: Hybrid jars [message #1234191 is a reply to message #1234173] |
Tue, 21 January 2014 07:41   |
Eclipse User |
|
|
|
If you look at the MANIFEST.MF generated? Does it hold the special
JavaFX-Launcher as the main-class?
If I remember correct JavaFX-Launcher does not call main but directly
bootstraps the application class and calls the start method.
What makes me wonder a bit because you said you have a Swing application!
Tom
On 21.01.14 12:54, Lior Giller wrote:
> I have some progress which might help understand the issue better.
> i realised (and maybe it was obvious but i missed it( that fro running
> from e(fx)clipse, i use "main" method., but if i want my jar to work, i
> need to use "start" method. i manages to get my simple system tray app
> working by copying my "main" code into the start, but from eclipse its
> stopped cause i have to have main.
> thats why i fail running as javafx jars, as it searches for the start
> method. also, on my mac, when i'm running from main all is ok, but same
> code running from start i get different result for if
> (!SystemTray.isSupported()) {
> System.out.println("SystemTray is not supported");
> return;
>
> running from eclipse- its supported, running from jar its not.
>
> Does that make any sense to you?
>
> Lior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|