Loading jni dll using default package vs. specified package

The following code:
public class TestJni {
     public static void main(String[] args) throws Exception {
     System.loadLibrary("artjnidll");
     NARTG_CoreLib test = new NARTG_CoreLib();
works so long as it is in my project's "default" package together with the jni source files.
when I try to separate the jni source files into a package, say "artjni" & try to run the following code:
import artjni.NARTG_CoreLib;
public class TestJni {
     public static void main(String[] args) throws Exception {
     System.loadLibrary("artjnidll");
     NARTG_CoreLib test = new NARTG_CoreLib();
i get an unsatisfied link error
Exception in thread "main" java.lang.UnsatisfiedLinkError: artjni.artAPIJNI.new_NARTG_CoreLib()J
     at artjni.artAPIJNI.new_NARTG_CoreLib(Native Method)
     at artjni.NARTG_CoreLib.<init>(NARTG_CoreLib.java:31)
     at testartjni.TestJni.main(TestJni.java:18)
even though the library loads fine. Can anyone help me understand why this is happening?
Thanks so much for the help, d.

jasro wrote:
Could you elaborate a little bit? Maybe provide an example? How exactly should I rename the jni wrapper functions?1. Run javah again.
2. Verify that the signatures in the h file match those in the c/cpp file.
3. Include the h file in the c/cpp file.

Similar Messages

  • Since loading the latest version of firefox i can no longer print. instead a message comes up "can not load library 'DLBAPRP.DLL' using defaults, error 126. what happened?

    error 126 can not load library "DLBAPRP.DLL" using defaults. this message appears when we try to print from our web bookmarks or any acrobat or pdf files

    That error seems to be new with Firefox 4 - never heard of it with earlier versions of Firefox, but it goes back many years in various Windows programs.
    See this [http://www.google.com/search?client=ubuntu&channel=fs&q=DLBAPRP.Dll&ie=utf-8&oe=utf-8 search].

  • Need to use default package for JNI code?

    Hi,
    I don't have much experience with JNI code, so excuse me if I make a silly mistake.
    I have a set of DLLs to interface with Microsoft native speech code ("Microsoft Sam") -- a GPL library called Quadmore. Quadmore has some sample Java code to work with the libraries, all of which they put in the default package (no package). If I move their code to a named package, it breaks. The Java code is able to load th libraries, but can't find any of the methods.
    Looking at the source for their DLLs (though I don't speak C++), the method names are things like
    JNIEXPORT jboolean JNICALL Java_QuadmoreTTS_SpeakDarling(JNIEnv *env,jobject obj,jstring strInput)As far as I understand, this implies that the QuadmoreTTS.class that calls the code must be in the default package, as otherwise the method name needs to be prepended with a package name.
    If that's so, then there's no way I can use the code as-is, right? Naturally, the rest of my program is in named packages, and I can't import any class that is in the default package, right? I've tried placing all their code in a jar and adding the jar to my classpath, but I still can't import any of their classes as they are in the default package.
    Is the only solution to re-compile all their C/C++ code to let it use packages? Am I being dumb and missing something? I'm pretty sure other people have used Quadmore before, so I can't believe that they've never had this problem before.
    Any suggestions greatly appreciated!
    Sam

    C/C++ functions in JNI must conform to the prototypes produced by running the javah compiler against the class file with native methods in it. So if you move the class to another package, the prototypes change. If you doun't change the compiled C coudes to suit, you will get undefined method errors when you load the dll as the JVM won't be able to match the native methods to the methods in the dll (it will call WinLoadLibrary() and WinLoadProcAddress() or somesuch under Windows).

  • Jdev crash when loading JNI dll

    Greetings:
    I have the following msg when I either
    click in "Design" tab or start debugger:
    -------------- cut here -------------
    JniPortal for D:\JDeveloper\java1.2\jre\bin\OJVM\jvm.dll reported
    Native Library D:\JDeveloper\java1.2\bin\JTACCDLL.dll already loaded in another classloader
    java.lang.UnsatisfiedLinkError: Native Library D:\JDeveloper\java1.2\bin\JTACCDLL.dll already loaded in another classloader
    void java.lang.ClassLoader.resolveClass0(java.lang.Class)
    void java.lang.ClassLoader.resolveClass(java.lang.Class)
    java.lang.Class borland.jbuilder.jot.JotClassLoader.loadClass(java.lang.String, boolean)
    java.lang.Class borland.jbuilder.jot.ClassManager.loadClass(java.lang.String, boolean)
    java.lang.Class borland.jbuilder.jot.JotPackageManager.loadClass(java.lang.String, boolean)
    int borland.jbuilder.uidesigner.$491.getType(borland.jbuilder.cmt.CmtSubcomponent, borland.jbuilder.cmt.CmtComponents)
    com.objectspace.jgl.Array borland.jbuilder.uidesigner.$491.$TGb(borland.jbuilder.cmt.CmtComponents, borland.jbuilder.cmt.CmtComponent, borland.jbuilder.cmt.CmtMethodSource)
    void borland.jbuilder.uidesigner.DesignerAddin.annotate(borland.jbuilder.cmt.CmtComponentModel, borland.jbuilder.cmt.CmtComponents)
    void borland.jbuilder.designer.DesignerManager.annotate(borland.jbuilder.cmt.CmtComponents, borland.jbuilder.cmt.CmtComponentModel)
    void borland.jbuilder.designer.DesignContext.open(borland.jbuilder.addin.Url, boolean)
    void borland.jbuilder.designer.DesignContext.changeUrl(borland.jbuilder.addin.Url)
    void oracle.jdeveloper.addin.impl.JavaMasterViewerImpl.changeViewerUrl(java.lang.String)
    void oracle.jdeveloper.addin.CustomViewer.changeUrl(java.lang.String)
    void oracle.jdeveloper.addin.JavaMasterViewer_JavaDispatch.invoke(int, borland.javaport.JavaCallStack)
    The jtaccdll.dll is my JNI dll. I am not sure
    why is it tryin to load when I launch "Design". The dll has nothing to do with
    screen objects.
    Before I put it in that place JDev was
    complaining that the dll is missing and
    refused to do anything (run debugger at all).
    Did anybody figured how to fix it? JDev
    is v3.1.1.2.
    TIA,
    V.
    null

    jasro wrote:
    Could you elaborate a little bit? Maybe provide an example? How exactly should I rename the jni wrapper functions?1. Run javah again.
    2. Verify that the signatures in the h file match those in the c/cpp file.
    3. Include the h file in the c/cpp file.

  • Since downloading new version, Printer issue "Can't load library DLBAPRP.Dll, Using Defaults Error:126"

    The printer will not work on some printjobs and I get the message shown in my question. Previous to downloading the new version of Firefox, no problem. And I can print these jobs when I use my internet explorer browser.

    That error seems to be new with Firefox 4 - never heard of it with earlier versions of Firefox, but it goes back many years in various Windows programs.
    See this [http://www.google.com/search?client=ubuntu&channel=fs&q=DLBAPRP.Dll&ie=utf-8&oe=utf-8 search].

  • UnsatisfiedLinkError for JNI DLL compiled with vs2008 express

    I am trying to create a JNI DLL using Visual Studio 2008 Express.
    I have read several places where -MD causes JNI problems but from what I've read, I need this option to create the DLL properly.
    The DLL does get built cleanly and I have created a simple C application (obviously not calling the JNI functions themselves but the other functions that are in the DLL). This application runs with no problems.
    As soon as I try to use the DLL with JNI, I get an UnsatisfiedLinkError: Can't find dependent libraries.
    I have used Dependency Walker on the C application I created and it finds no errors; however, if I run it on the DLL itself, it does report an error trying to find msvcr90.dll which is in the winsxs directory under c:\windows so I assume this is the problem dependency.
    I am running this on the same computer that has Visual Studio 2008 Express SP1 installed. This is a Windows XP Service Pack 3 computer running JDK 1.6.0_14.
    Any help would be greatly appreciated.
    Thanks

    Right or wrong, I include some library files into my link statement (it's the only way I could find to clear up your question). I link in some standard window libraries as well as some of my own DLL whose functions are used by this DLL. I use a makefile to build my code.
    Here is a compile statement and the link statement for my DLL:
    cl.exe -I c:\progra~1\micros~1.0\vc\include -I c:\progra~1\mi2578~1\windows\v7.0\include -I c:/progra~1/java/jdk1.6.0_14/include -I c:/progra~1/java/jdk1.6.0_14/include/Win32 -I S:/wlw/Develop/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/Example -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/User -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/User -DRTA_DLL -D_BIND_TO_CURRENT_VCLIBS_VERSION -Zp4 -DWIN32 -D__WIN32__ -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_WARNINGS -nologo -W3 -Od -EHsc -MD -Z7 -c buildDate.c
    link.exe -incremental:no -nologo -debug kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib -dll -out:S:/wlw/Products/Obj/Win32/Lib/rta.dll -implib:S:/wlw/Products/Obj/Win32/Lib/rta.lib eipc_client.obj eipc_usersys.obj eips_pccc.obj eips_cnxn.obj eips_cpf.obj eips_encap.obj eips_iomsg.obj eips_rtasys.obj eips_timer.obj rta_utils.obj eips_userdf1.obj eips_userobj.obj eips_usersock.obj eips_usersys.obj jniRta.obj jniRtaPlc.obj jniRtaPlcAddress.obj qcRta.obj qcRtaPlcAddressLink.obj qcRtaPlcLink.obj qcRtaProcess.obj qcRtaRead.obj qcRtaSlcRead.obj qcRtaSlcWrite.obj qcRtaState.obj qcRtaTimer.obj qcRtaWrite.obj Q:/Develop/Obj/Win32/Lib/tcpipNet.lib Q:/Develop/Obj/Win32/Lib/linkList.lib Q:/Develop/Obj/Win32/Lib/stdUtils.lib buildDate.obj
    mt -manifest S:/wlw/Products/Obj/Win32/Lib/rta.dll.manifest -outputresource:S:/wlw/Products/Obj/Win32/Lib/rta.dll;2

  • Creating JNI DLL on WinXP using MinGW and GCC

    Ohh man, I spent entire day fighting with "UnsatisfiedLinkError "while trying to cal my native method. After reading all the posts with similar problems, and checking for every little thing that was suggested I figured it out. So I'm reposting the solution here since no one else had suggested this.
    The solution to my problem was that g++/gcc compiler needed an option "-Wl,--add-stdcall-alias". This was the killer. I had the "-shared", but it wouldn't link without the "-Wl,--add-stdcall-alias" option!!!
    As a summary, while its fresh in my mind, here are the trouble shooting steps I used:
    1) Check package names and the generated .h file using javah. I checked and rechecked the names, even created simpler static void method to try and get it to link.
    2) Make sure to use the "jobject" parameter for dynamic methods and "jclass" for static methods in the signature as second argument.
    3) That method name starts with "Java_" and I stress the CAPITAL "J", can not be lowercase. Although if you are using javah, that should not be the problem, since javah can not ommit this kind of detail. The only thing that you need to check for is that if you change method from dynamic to static, and don't rerun the javah, or javah doesn't replace the previous file. So make sure you restart clean and that javah regenerated the file with "jclass" or "jobject" whichever is the case.
    4) Used the "java -verbose:jni" debug flag to see my native method loaded. In my case when it wasn't working I couldn't see the method load, but there were no error messages from "System.loadLibrary" or from the verbose output. Only the UnsatisfiedLinkError. Frustrating. After the fix it loads perfectly:
    [Dynamic-linking native method org.jnetpcap.Pcap.openVoid ... JNI]5) I used "nm" found at "c:/MinGW/bin/nm.exe" to dump the symbol table, and I could see all my methods, with the appropriate named marked as text (T) flag. They were not being loaded when viewed using "java -verbose:jni" though.
    6) I put "extern "C" {}" around all my JNI C++ methods.
    7) Tried a gazilion other gcc options, posted in various messages, none worked.
    8) Finally came accross the "-Wl,--add-stdcall-alias" flag which fixed it.
    Here is a portion of my Makefile for reference:
    $(LINK_TARGET) : $(OBJS)
         g++ \
              -shared \
              -Wl,--add-stdcall-alias \
              -o $@ $^ \
              $(LIBDIRS) $(LIBS)LIBDIR and LIBS point to a single external library dependency.
    My IDE environment is Eclipse 3.2, but I run everything from Makefiles as external programs.
    I wish this was documented somewhere, would have saved me an entire day of troubleshooting.
    Cheers,
    mark...
    Message was edited by:
    voytechs - added CODE tags

    Glad my post helped out at least a few people.
    Believe it or not, I'm in the same boat now on Linux.
    Atleast I know its the name mangling problem again. I
    see a few symbols unmangled with nm, but most are,
    and those are then one's JNI is complaining about
    with UnsatisfiedLinkError.
    So now I'm going through various post related to
    linux and trying to find the same type of flag. The
    "alias" flag doesn't work with RH4 g++ version
    4.0.2.You should not need a flag on Linux. A typical compile for me on my Linux box is:
    gcc -shared -o libjnitest.so -I/usr/java/jdk1.6.0_01/include -I/usr/java/jdk1.6.0_01/include/linux jnitest.c>
    Window builds perfectly fine, but now I'm creating a
    new platform target. Everything compiles and creates
    the shared library, just can't get JNI to be happy.
    BTW, my project: http://jnetpcap.sf.net
    Ah. You have .cpp extensions on your filenames. Are you using gcc or g++ to compile? If you don't use g++, you can get errors such as:
    undefined symbol: __gxx_personality_v0
    Jim S.

  • Call to a C++ DLL, using JNI - C++ method has char*

    I am trying to link into an existing C++ Dynamically Linked Library(DLL) using the Java Native Interface(JNI).
    All goes fine, and the library loads into the current program, however when I try to call the function, it crashes. The function has char pointers, and I haven;t been able to get Java to simulate them. Is there a way?????
    I have tried using and array of chars .....char[], and String, but no dice.
    Any suggestions O'learned Java ones??

    It will be necessary for you to write a JNI adapter in C/C++ to accomplish this. Java character strings and arrays are very different from those of C/C++ and you'll have to use JNI functions to adapt.
    Chuck

  • Loading a DLL without JNI

    I'm new to java, but I've been programming for a long time, and I'm looking for a way to load a DLL into java. I see a lot of places online that talk about using JNI, but I'm terrible with C++, so that's not really an option for me.
    I also see various places that say you can just use System.load("C:/...x.dll") but none of them have code for actually executing one of the methods in x.dll...
    Thanks in advance,
    bmad6

    You may want to check out something called Jacob - this is a Java to COM bridge (hence the name I guess) and you should be able to get it either at Sourcforge, download.com or by searching the 'net.

  • Calling Functions of Loading DLL using java

    I have a dll file
    I know the functions which are ther in the dll
    But how to call those functions using JAVA ?
    can anyone tell me how to do the same...
    Thanx in advance
    regards,
    Ritesh

    I assume that you have a regular DLL and that the functions in that DLL are exported and that you know the signatures of each function.
    With that in mind, you will need to use the Java Native Interface (JNI), to call those functions from Java. In a nutshell, you will need to create at least one class which declares some native methods, code a class static code block to load the JNI-DLL you are about to create, compile the class(es), run the javah tool supplied with the JDK which will emit a C compatible header file, implement the functions from the generated header file and compile that source file to into a DLL. It would be in this DLL that you would use the functions in the DLL that you ultimately want to access. So, what you wind up doing is creating a wrapper DLL.
    Take a look at the JNI tutorial trail from Sun at http://java.sun.com/docs/books/tutorial/native1.1/index.html.

  • When trying to upload a document or attach a document in an email Firefox gives me an error "Failed to load CTDFMRES.dll" and stops responding, I have no issues in any other browsers. And I am using Firefox 4, Fixes???

    When trying to upload a document or attach a document in an email Firefox gives me an error "Failed to load CTDFMRES.dll" and stops responding, I have no issues in any other browsers. And I am using Firefox 4, Fixes???

    You don't have to disable any addons or extentions!!!You guys are not going to believe this I figured out the problem it's really dumb...ok here goes the attachment uploader loads seperate so I got to thinking it's a popup so I went to options content and under block pop ups there is an option exceptions click on that and in the box type firefox.com and hit allow pow its fixed!!!!! :-)

  • Problem calling C# dll using JNI

    Hi,
    I'm trying to call C# functions from a JNI interface. I built a C++ DLL to link the Java and C# calls together, but I am always getting the same error. Calling the C# DLL directly from the C++ code (compiled as an application) does not cause this error. I have to be able to connect our java application with a third party C# DLL, so I cannot just right the DLL directly in C++... Here is my code:
    //C# Class Library::
    namespace ClassLibrary2
         /// <summary>
         /// Summary description for Class1.
         /// </summary>
         public class Class1     
              public Class1()
                   // TODO: Add constructor logic here
              public void Bidon1()
         MessageBox.Show("Affiche", "Toi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    //C++ DLL::
    #using "ClassLibrary2.dll"
    BOOL APIENTRY DLLMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {
      return TRUE;
    JNIEXPORT void JNICALL Java_com_blablabla_CommJNIDLL_Init
    (JNIEnv * enivronmt, jobject obj)
         new ClassLibrary2::Class1();
         (new ClassLibrary2::Class1())->Bidon1();
    Olivier dit :
    //Java JNI Calls::
    //From CommJNIDLL::
         static {
              System.loadLibrary("MyCDLL");
         public native void Init();     If I comment the calls within the C++ DLL, they get fired, and no exception is raised. What am I doing wrong?
    Thanks, bumpert

    Hi,
    I am currently also trying to call some C# code within JNI. So far I have managed to call some simple C# code in Java through JNI based on the example on codeproject. However, now my problem is that instead of doing JNI-->C++->M C++->C#, I need to include one more reference to some other DLLs in the C# code. Therefore I need to do JNI-->C++-->M C++-->C#-->DLL. So is there a way to do this? I can compile all the code sucessfully in C++, but when I try to execute the .netmodule (for C#) and DLL for C++ through JNI in Java, it gives me an error. I have tried to put all the relevant DLLs in the same directory, but it still does not work. So is there someway to combine the .netmodule of C# with the DLLs it references to? Perhaps that could solve the problem? I am new to C# and C++, really appreciate if someone can give some advices since there's nothing much on the net.
    thanks,
    Lee

  • Specified driver could not be loaded due to system error 127: The specified procedure could not be found. (...SQORA32.DLL).

    I recently upgraded from 10g to 11g and upon this upgrade, a website of mine stopped working.
    It is a classic ASP website.  I added a "testdatabase" page to the website to test the basic functionality of opening a connection.  I've pasted the testdatabase page below.  Anyways, upon running this page, I get this error:
    Specified driver could not be loaded due to system error 127: The specified procedure could not be found. (Oracle in OraClient11g_home1_32bit, D:\app\oracleadm\product\11.2.0\client_1\BIN\SQORA32.DLL).
    I have two other environments where I have done the same upgrade and the site works just fine.  I have compared all the IIS settings in my other environments to that of the one suffering from the error.  Also, in the IIS settings, I have made sure that "Allow 32bit" was checked.
    D:\app\oracleadm\product\11.2.0\client_1\BIN\SQORA32.DLL is actually where this DLL resides. 
    I have also checked to make sure the environment variables are correct.
    The very first environment variable in the PATH setting is D:\app\oracleadm\product\11.2.0\client_1\bin; and there are no other references to oracle in the PATH environment variable.
    I have done a google search and I've seen that people also tell me to check ORACLE_HOME to make sure it's correct.  I've checked this in both of the working environments and there is nothing there.  There is also nothing there in the broken environment.  What should be there?  If anything?
    I don't know where else to look.  What could be causing this error?
    <%
    Option Explicit
    Response.Expires = 0
    Response.Buffer  = true
    Dim conn
    Err.Clear
    On Error Resume Next
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "DSN=RPS11;UID=FFXQM;PWD=ffxqm6prd$"
    If Err.Number <> 0 Then
    Response.Write (Err.Description & "<br><br>")
    Response.End
    conn.Close
    Set conn = Nothing
    End If
    conn.Close
    Set conn = Nothing
    On Error GoTo 0
    %>

    As a temporary solution, add the Administrators group to the IUSR and IWAM userids and see if that works. If it solves the problem, then it IS a matter of setting the users privledges correctly.

  • Calling COM DLLs using JNI

    I am able to call ordinary dlls from my java application using JNI, by exporting the function from my DLL.
    What can I do to call COM DLLs using JNI which do not expose the
    Functions directly.
    please help!
    thanx,
    -sachin

    Is this a COM dll that you have written or do you merely have the dll?
    If you merely have the dll, there are some third party tools that will generate Java interfaces to COM objects from the dll.
    Although I don't endorse these products or work for them I've used them before with some success:
    o J-Integra -- http://www.intrinsyc.com/
    o jacoZoom -- http://www.infozoom.de/
    -- rob

  • To add the JNI dll to the jar file and use the dll inside the jar file

    Hi to everybody,
    I am new to java.
    I want to add the JNI dll to the jar file and use it in the java class.
    How can I achieve it.
    Please help me.
    Thanks in advance.
    Regards,
    M.Sivadhas.

    can't be done because none of the known operating systems support reading binary libraries from .jar files ... you can add the binary to the jar but then you have to extract it...
    besides, mixing platform specific and platfrom independent components is not a very good idea, i'd keep the dll out of the jar to begin with

Maybe you are looking for

  • Adding New Field in table control

    Hi all, I am going to add one new field in existing table control ,which already contains nearly 20 fields, so my field should be21st field, here when I am going to add new field , I need to add the field from work are from the same program. So , I a

  • Is windows 8 already supported in OSX lion bootcamp?

    is windows 8 already supported in OSX lion bootcamp?

  • Exporting to and from Garageband

    Can you share from Garageband to DVD Studio Pro. As you can't seem to embed the sound track into your movie from Garageband I am wondering if you can export the video and audio tracks to somewhere other than iDVD.

  • Regular silent calls from BT (!!) on a TPS registe...

    008007312687 is ringing me several times a day and is silent/clicks and breaks call when answered. Search on internet shows this to be coming from BT Broadband Sales. I am registered with the TPS. How do I put a stop to these calls ?? I have already

  • How to deploy archive viewer in enterprise - weblogic edition

    Hi, I was looking for documentation, to see how I can deploy the archive viewer to weblogic. I read the documents and come to know that the archive viewer war needs to be deployed to the weblogic. But I do not know where I can get the archive viewer