Re: System.load() problem

From: Gordon Beaton (not_at_for.email)
Date: 08/12/04


Date: 12 Aug 2004 09:33:49 +0200

On Thu, 12 Aug 2004 06:31:47 GMT, cppaddict wrote:
> Then I moved my project to a new folder and gave it a new package
> name. However, I did not change or move my .DLL, and the code that
> calls it (above) was untouched. However, I am now getting an
> UnsatisifiedLinkError at runtime when my app hits the first native
> method call. Why is this happening? How can I fix it?

Since UnsatisifiedLinkError occurs at method invokation, it means the
JVM cannot find the required symbol in the DLL. (Had the error occured
at System.load() it would have meant that the JVM could not find the
DLL, or that loading failed for some other reason).

The native symbol names the JVM expects to find depend on the fully
qualified name of the class to which they belong. You changed the
package name, so essentially your native methods no longer belong to
the class.

Re-run javah to get a new list of symbol names, rename the symbols in
the C file, and recompile the DLL. Note that you need to specify the
_fully_qualified_ classname when you run javah.

If you call RegisterNatives() from JNI_OnLoad() you can name the
symbols anything you like, without regard to the package name or the
java-declared native method names. It lets you provide an explicit
mapping from the java-names of your native methods to the actual names
in the DLL source. RegisterNatives() still needs to know the fully
qualified classname, but since the information is in a single place
you don't need to re-run javah and you don't need to rename anything.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e


Relevant Pages

  • Re: Question about loading a DLL
    ... tells the package loader how to find/load the package, ... Then you can load/initialize the dll via: ... - load has no path to search ... initialization procedure will have the form pkg_Init, where pkg is the same as ...
    (comp.lang.tcl)
  • RE: Executing a DTS Package from VB.NET forms
    ... Use TlbImp.exe to import the main DTS DLL file into ... Reference this file in your .NET code. ... I am trying to execute a package from a remote SQL Server. ... SQL Server authentication. ...
    (microsoft.public.sqlserver.dts)
  • Re: Linking or Compiling Dependencies into a .Net Assembly
    ... When I include the dll in another project, ... When I package Project B and deploy it on ... failed to start because the application configuration is incorrect. ... Reinstalling the application may fix this problem. ...
    (microsoft.public.dotnet.languages.vc)
  • =?ISO-8859-1?Q?Re=3A_Obergrenze_der_Anzahl_aus_Unit/DL?= =?ISO-8859-1?Q?L_exportiert
    ... In der bpl sind alle routinen usw als exports drin, jedoch mit Klassennamenprefix und aehnlichen Sperenzchen (Package Framework von Delphi). ... Die dcp Files sind AFAIR eher der exports files von Visual Studio vergleichbar bzw. eher eine mini .lib, welche die ganzen Exports des package nochmals beinhalten und hart referenzieren (Stichwort: ...
    (de.comp.lang.delphi.misc)
  • Re: Accessing variables and function in the MAIN program from a FORM
    ... A package containing shared information, such as common routines, ... A package to replace the above DLL. ... I think the op is trying to do cross communications with the amps that ...
    (alt.comp.lang.borland-delphi)