3

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?

icedwater
  • 4,701
  • 3
  • 35
  • 50
posdef
  • 6,498
  • 11
  • 46
  • 94
  • IIRC, Eclipse allows you to specify a different classpath than you have on the command line; you may be missing some dependencies/libraries in your JAR. – Piskvor left the building Oct 13 '10 at 11:36
  • As far as I can tell, all the libraries are included in the jar file, I have especially checked the swt package: swt-3.4.2-gtk-linux-x86.jar. As for the classpath, there is nothing specific there in the Run Configurations. It's really odd as I have managed to do the same thing with an older version of the same project, and I dont recall having so many problems with it. – posdef Oct 13 '10 at 11:53
  • If on **Windows** try running as **Administrator** – Joshua Drake Apr 23 '14 at 13:44

2 Answers2

0

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
  • 18,554
  • 22
  • 89
  • 134
  • 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 Oct 13 '10 at 11:46
  • 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 Oct 13 '10 at 11:55
  • 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 Oct 14 '10 at 07:33
0

It turns out that eclipse runs the 32-bit JVM on my machine (for some weird reason) and yes it was about the os and arch specific libraries for SWT. For those who have similar problems please refer to the threads below for more info:

Problems with loading resources during execution

Running SWT based, cross-platform jar properly on a Mac

Good luck,

Community
  • 1
  • 1
posdef
  • 6,498
  • 11
  • 46
  • 94