views:

79

answers:

2

I have been working on packing a project lately but it has turned into a nightmare. So here's the problem in a nutshell. I have a project that I'd like to have as a jar file, and eventually use it as Java Web Start.

When I try to build and run the code through Eclipse, it works fine. However when I export it as a "runnable jar" and try to run it via terminal I get cryptic exceptions that seem to depend on the referenced libraries. I have checked that the libraries are there in the jar file so it's not that they are missing.

Depending on how I export it the specifics of the exception changes while it seems to originate from the same problem. Below is the stack trace thrown when the project is exported with depending libraries packaged as jars inside the "main" jar.

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ExceptionInInitializerError
at org.eclipse.gef.tools.MarqueeSelectionTool.<init>(MarqueeSelectionTool.java:99)
at org.gvt.MarqueeZoomTool.<init>(MarqueeZoomTool.java:16)
at org.gvt.action.MarqueeZoomToolAction$1.<init>(MarqueeZoomToolAction.java:28)
at org.gvt.action.MarqueeZoomToolAction.createTool(MarqueeZoomToolAction.java:28)
at org.gvt.action.AbstractGEFToolAction.<init>(AbstractGEFToolAction.java:24)
at org.gvt.action.MarqueeZoomToolAction.<init>(MarqueeZoomToolAction.java:20)
at org.gvt.TopMenuBar.createBarMenu(TopMenuBar.java:113)
at org.gvt.ChisioMain.createMenuManager(ChisioMain.java:612)
at org.eclipse.jface.window.ApplicationWindow.addMenuBar(ApplicationWindow.java:235)
at org.gvt.ChisioMain.main(ChisioMain.java:144)
... 5 more
Caused by: java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.graphics.Resource.<init>(Unknown Source)
at org.eclipse.swt.graphics.Cursor.<init>(Unknown Source)
at org.eclipse.draw2d.Cursors.<clinit>(Cursors.java:170)
... 15 more

By the way, I saved the XML / ANT output of the exporting process which I could add her if it could be of interest. I chose to omit it for the sake of less clutter.

Any ideas as to what might be the problem here?

EDIT: I am starting to think if it's a 32/64-bit problem with the SWT-GTK library. Can anyone confirm or deny this?

A: 

The exception you have here is not about dependencies. It's a programming error: "some one is passing a null argument to an SWT method that doesn't allow it).

According to the stack trace you are using GEF. How do you run your code in Eclipse, as java application or Eclipse application ?

If you are speaking about Eclipse application, you can't simply export it as a runnable Jar. You will have to create an RCP. Look on Google for RCP tutorial, you'll find many interesting result.

Manuel Selva
I do realize that the null argument problem there, however if it had anything to do with my programming it would have failed to execute when running from Eclipse. The code is running as Java Application btw
posdef
So you have a standalone Java application using SWT/Draw2d/GEF. Is it right ? After looking closely it seems you have an error when creating the cursor. According to SWT: "ERROR_NULL_ARGUMENT - if device is null and there is no current device " Because Draw2d is creating in a static way SWT cursors with null argument, it relies on the fact that there is a current device. This means the current thread is the main thread I think.
Manuel Selva
I am not 100% sure I follow you on that one, but why would drawing the cursor be a problem when it's running in a terminal while it's clearly no problem when the software is run via eclipse?
posdef