File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Invoking DLL from a Swing GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Invoking DLL from a Swing GUI" Watch "Invoking DLL from a Swing GUI" New topic

Invoking DLL from a Swing GUI

Jeroen Oosterlaar

Joined: Feb 11, 2007
Posts: 12

I have succesfully completed an Java gateway to a DLL so that the functions within the DLL can be invoked. Everything works fine when running the application from the command line. However, now I have developed a Swing GUI to enhance the usability, but when invoking the DLL from the GUI as a result of a butten click event, I get an exception starting with "Exception in thread "AWT-EventQueue-0" (...)". I guess it has something to do with a multithreading issue? Does anyone know how to solve this?

Thanks in advance and kind regards,

Jeroen Oosterlaar
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42263
I wouldn't think that it's a threading issue, but rather that a case of the library not being found. Is the DLL in your PATH? Also, post the full stack trace.

Ping & DNS - my free Android networking tools app
Jeroen Oosterlaar

Joined: Feb 11, 2007
Posts: 12
Currently, I can't get to the application, so I can't post the exception stack trace, yet, but I'm absolutely sure it is not caused by the library not being found. In fact, the exception output contains a messsage that is given by the DLL itself, saying that it fails at some stage during initialization. So, the loading of the DLL is succesfully established, but it fails to initialize (more specifically: it fails loading the book keeping administration that will be manipulated by our Java application). And this error only comes up, when the class that takes care of the DLL communication is instantiated and instructed to set up the connection from the GUI (after clicking a button). It does, however, run completely succesful, when the DLL communicating class is instantiated and instructed to set up the connection directly in the public static void main(String[] args) method:

[ February 28, 2007: Message edited by: Jeroen Oosterlaar ]
Jeroen Oosterlaar

Joined: Feb 11, 2007
Posts: 12
Ok, I have the output of the exception that is thrown, when the DLL is invoked from my Swing GUI:

Exception in thread "AWT-EventQueue-0" Er is een fout opgetreden tijdens het openen van de administratie.

Fase 9: controle demo. Object variable or With block variable not set
at Method)
at nl.viab.snelstart.dll._clsGWaySnelStart.mtdGWayAdmiOpenen(
at nl.viab.snelstart.Executor.<init>(
at nl.viab.snelstart.GUI.jButton1ActionPerformed(
at nl.viab.snelstart.GUI.access$000(
at nl.viab.snelstart.GUI$1.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(
at javax.swing.AbstractButton$Handler.actionPerformed(
at javax.swing.DefaultButtonModel.fireActionPerformed(
at javax.swing.DefaultButtonModel.setPressed(
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
at java.awt.Component.processMouseEvent(
at javax.swing.JComponent.processMouseEvent(
at java.awt.Component.processEvent(
at java.awt.Container.processEvent(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.LightweightDispatcher.retargetMouseEvent(
at java.awt.LightweightDispatcher.processMouseEvent(
at java.awt.LightweightDispatcher.dispatchEvent(
at java.awt.Container.dispatchEventImpl(
at java.awt.Window.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

Some relevant code regarding invoking the DLL from the GUI:

However, when new Executor() is called from the command line...

...everything runs completely succesful.
I agree. Here's the link:
subject: Invoking DLL from a Swing GUI