🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1130

Problems running a Windows DLL

#1130
From: Paul Trimming
Date: Wed, 15 May 2002 13:12
113 lines
4453 bytes
Hello,
I am a very new Java programmer with some difficulties.

I am trying to run a Windows (C++) DLL MyWindow from within Java becuase the
DLL has some functionality that I need for the Windows platform.  The
controlling Java class (also MyWindow) is quoted below.  I find if I put all
the components in one directory, and run them from the commandline, there is
no problem.  However, if I run it from within JBuilder Personal, I get the
following error:

java.lang.UnsatisfiedLinkError: initialize
 at lpsemail.MyWindow.initialize(Native Method)
 at lpsemail.MyWindow.addNotify(MyWindow.java:46)

It would seem that it can find the DLL, but cannot find the native routine
"initialize" within it.  I got a different error previously when it couldn't
find MyWindow.DLL at all.  So far I have put the DLL in the root directory
of the JBuilder project.  As I do all my work in JBuilder this problem
drives me nuts.  I have not changed the classpath or path, as when I run it
from the commandline, none of that is needed.

I would be very grateful for any suggestions as to why it cannot find the
"initialize" routine inside the DLL.
Thanks,
Paul Trimming


package lpsemail;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.peer.*;
import sun.awt.*;

public class MyWindow extends Canvas
{
   String m_strURL = "http://www.javasoft.com";
    static
    {
        // Load the library that contains the JNI code.
        System.loadLibrary("MyWindow");
    }

    // native entry point for initializing the IE control.
    public native void initialize(int hwnd, String strURL);

    // native entry point for resizing
    public native void resizeControl(int hwnd, int nWidth, int nHeight);

    // Returns the HWND for panel. This is a hack which works with
    // JDK1.1.8, JDK1.2.2 and JDK1.3. This is undocumented. Also
    // you should call this only after addNotify has been called.
    public int getHWND()
    {
        int hwnd = 0;
        DrawingSurfaceInfo drawingSurfaceInfo =
((DrawingSurface)(getPeer())).getDrawingSurfaceInfo();
        if (null != drawingSurfaceInfo)
  {
            drawingSurfaceInfo.lock();
            Win32DrawingSurface win32DrawingSurface =
(Win32DrawingSurface)drawingSurfaceInfo.getSurface();
            hwnd = win32DrawingSurface.getHWnd();
            drawingSurfaceInfo.unlock();
        }
        return hwnd;
    }

    public void addNotify()
    {
        super.addNotify();
        m_hWnd = getHWND();
        initialize(m_hWnd, m_strURL);
    }


    int    m_hWnd   = 0;

    public void getURL() {
    initialize(m_hWnd, m_strURL);
    }


    public void setSize( int width, int height )
    {
        super.setSize(width,height);
        if(m_hWnd!=0)
            resizeControl(m_hWnd, width, height);
    }

    public void setSize( Dimension d )
    {
        super.setSize(d);
        if(m_hWnd!=0)
            resizeControl(m_hWnd, d.width, d.height);
    }

    public void setBounds( int x, int y, int width, int height )
    {
        super.setBounds(x,y,width,height);
        if(m_hWnd!=0)
            resizeControl(m_hWnd, width, height);
    }

    public void setBounds( Rectangle r )
    {
        super.setBounds(r);
        if(m_hWnd!=0)
            resizeControl(m_hWnd, r.width, r.height);
    }
}
Technical Details
Message-ID: <m8tE8.922$UL2.69284@newsfep1-win.server.ntli.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!newspeer1-gui.server.ntli.net!ntli.net!newsfep1-win.server.ntli.net.POSTED!53ab2750!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,716a7781c3662f09,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-05-15 06:11:47 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!newspeer1-gui.server.ntli.net!ntli.net!newsfep1-win.server.ntli.net.POSTED!53ab2750!not-for-mail
From: "Paul Trimming" <paul.trimming@ntlworld.com>
Newsgroups: borland.public.jbuilder.java.api
Subject: Problems running a Windows DLL
Lines: 115
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <m8tE8.922$UL2.69284@newsfep1-win.server.ntli.net>
Date: Wed, 15 May 2002 14:12:47 +0100
NNTP-Posting-Host: 80.0.75.145
X-Complaints-To: abuse@ntlworld.com
X-Trace: newsfep1-win.server.ntli.net 1021468306 80.0.75.145 (Wed, 15 May 2002 14:11:46 BST)
NNTP-Posting-Date: Wed, 15 May 2002 14:11:46 BST
Organization: ntl Cablemodem News Service