UnsatisfiedLinkError when loading library from within package

I have a piece of working code (simplified for easier reading):
NativeLibraryLoader.java
public class NativeLibraryLoader{
     static { System.loadLibrary("TheLibrary"); }
     public static native void someFunction(String someVariable);
     public static void main (String[] args) {
          int someInt = SomeClass.anotherFunction();
          System.out.println(someFunction("string"));
}SomeClass.java
public class SomeClass{
     public static int anotherFunction(){
          return 1;
}This all works great and does what I want it to do.
However: If I add the line
package com.yifanlu;to the beginning of both files, I get the following error: Exception in thread "main" java.lang.UnsatisfiedLinkError: com.yifanlu.someFunction
For some reason it can't find my library file. What's even weirder is that if I change the line in NativeLibraryLoader.java from "static { System.loadLibrary("TheLibrary"); }" to "static { System.load("C:/TheLibrary.dll"); }" (which exists), I still get the same error.
Is there some rule for packages and JNI I should know about?

When you change the package it changes the C/C++ function name that must be used so you must re-run javah and update the C/C++ method names so as to match those generated by javah.

Similar Messages

  • Load library from JAR file

    Could I ask you guys a stupid question, please?
    I have a library as an JAR file. I build my application as another JAR file, which includes that library file.
    My manifest file is:
    Manifest-Version: 0.1.0
    Class-Path: lib/mysql-connector-java-3.0.17-ga-bin.jar
    Main-Class: com.myappand the build command:
    jar cvfm hello.jar mymanifest -c com  -c libThe result hello.jar file built OK. But when I run it, I have to copy library file to the same folder to the app file.
    Could you tell me how to load the lib file from hello.jar, instead of the lib file?
    Thanks in advance!
    Best regards,
    Lehoanq

    am I right in thinking you've put the mysql jar inside your application jar? jars don't work like that, I'm afraid. it is possible to write a classloader that will load classes from within a jar-inside-a-jar, but it gets rather complicated and messy and isn't worth the hassle to be honest, anyway. we go to some lengths to keep our software modular and separate. imagine, for instance, that a bug is exposed in the mysql driver you're using, and a new release is needed to fix it. the dependency is rooted inside your application, so the whole shebang has to be re-packaged and re-deployed, whereas if your dependencies were inside a lib folder, all that would be needed is to drop the new version of the mysql driver into the lib directory. think "don't put all your eggs in one basket"
    what you want to do is possible, and there are tools around to do it for you, too, but IMHO it's not worth the effort

  • Failed to load XML from the package file "" due to error 0xC00CE556 "Invalid at the top level of the document.Line.

    Using Installation wizard to deploy SSIS packages from DEV server to QA server package store cause this error;
    Failed to load XML from the package file "" due to error 0xC00CE556 "Invalid at the top level of the document. Line 773, Column 93". This happens when loading a package and the file cannot be opened or loaded correctly into XML document.  This can be the
    result of either providing an incorrect file name to the LoadPackage method or the XML file specified having an incorrect format.  Please who have the idea of how this issue can be resolved?BI Developer

    Hi ,
       for this Error one and only one solution 
    go to view Code, line number and Column number shown in error message,
    and Remove code from there till last and save it,  it happens when we are moving Package from one server to another server. and VS adds some lines of code at the bottom of package
    something like this 
    andles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0">
        <control>
          <ddsxmlobjectstreaminitwrapper binary="00080000921400008c040000" />
        </control>
        <layoutobject>
          <ddsxmlobj>
            <property name="LogicalObject" value="{BBFB0E
    Remove this code and save package it will work.  
    hope this will help to Developers who are searching for same ......... :) 

  • Loading library from jar file

    Hi all,
    My question is can we load library from jar file using System.load() method.
    ex:
    myJar.jar
    |
    |----com.test.common.Util
    which conatins a method to load library from jar file itself, before that i used to load from File
    |---libraries/MozillaParser/......
    Iam able load from Local system,
    File parserLibraryFile = new File("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    File mozillaDistBinDirectory = new File("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(parserLibraryFile.getAbsolutePath() , mozillaDistBinDirectory.getAbsolutePath());
    but i am unable to load from jar file
    URL url = ClassLoader.getSystemClassLoader().getResource("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    URL url1 = ClassLoader.getSystemClassLoader().getResource("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(url.toString(), url1.toString());
    Thanks in advance.

    That's a really confusing post.
    The easiest way to make sure you can use the classes in a jar file is to copy the jar file to the "/jre/lib/ext" subfolder of your JDK. These classes will be visible to all applications.

  • RoboHelp 11 - When previewing topics from within the project, a script error displays: 'HHComponent Activator' is undefined. How do you get rid of this script error?

    RoboHelp 11
    When previewing topics from within the project, a script error diplays: 'HHComponent Activator' is undefined.
    How do you get rid of this script error?

    Hi there
    Have you tried clicking Help > Updates and applying the service release?
    If not, I'd start with that.
    Cheers... Rick

  • Satellite L500-19x crashes when loading software from dvd

    Satellite L500-19x crashes when loading software from dvd. This is photoshop elements 9. Other software generally loads ok, but not always.
    Any ideas?

    Hi shownomercer,
    Have you tried the Photoshop disk in another computer to check if the installation disk is ok or not?
    What happens exactly when the computer crashes? Bluescreen?

  • Java.lang.UnsatisfiedLinkError when loading libaries

    Hi,
    I coded an ejb, in which I want to call funtionality coming from a dll via JNI.
    In order to achieve it I copied the libary 'XXX.dll' to the windows directory system32
    and call in my ejb : System.loadLibary("XXX").
    The following exception occured:
    javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no XXX in java.library.path
    Can anybody help me by saying
    1) where to put the .dll and what path to set in calling System.loadLibary(...)
    3) or even where and how to set the java.libary.path variable (Instance Template via configtool?)
    Honour and points are garanteed.
    Jens

    Hi,
    Check This,
    File f = new File("C:");
    System.out.println(f + " \t" + f.exists());
    f = new File(f, "sampleDLL2");
    System.out.println(f + " \t" + f.exists());
    System.load( f.toString() );
    When the library can not be found, you get a java.lang.UnsatisfiedLinkError with the message "no library in java.library.path". To solve this, move the library in one of the directories specified by java.library.path or alter the property so that it points to the directory containing your library. You can print this property with the following code:
    1: System.out.println(System.getProperty("java.library.path"));
    Another possibility when things do not work is when the DLL can be found, but the methods can not. A DLL exports functions according to specific names an calling conventions. When your compiler is not configured the right way your methods may get anther name than they should be. To solve this, you should include the header file generated by javah and configure your compiler the right way.
    Thanks,
    gopal

  • Instantiating Objects from the library from within the movie clip

    Ive been Instantiating Library object from linked external
    action script files and it works fine.
    var PPEbtn1 = new btnPPE;
    but when i try to do it from within the main swfs timeline it
    fails to work and i recieve an error if anyone could please help it
    would be most apreciated. thanks

    You need to get the application domain of the external swf
    and use its getDefinition method. Cast the result to a Class and
    then you can instantiate the symbol.
    Here's some example code where "library" is an externally
    loaded swf:

  • How Do I Solve this Problem when Copying Library from Backup Disks?

    I recently had a pc problem that resulted in the repair company having to back up my hard drive (which included my I Tunes Library) onto DVDs.
    When trying to upload the ITunes library from the DVD to my new computer (after downloading I Tunes software), about half of my library uploaded fine.
    The other half is indicated in my new I Tunes library, but when I click on it it says that such songs "could not be used because the original file could not be found. Would you like to locate it?"
    When I attempt to locate it, I cannot find it on the disk. But it must be there, I am guessing, because it loaded, albeit in the inaccessible form, into the new I Tunes library?
    When I open the disk in my D drive, I cannot find the songs that will not open; it appears that the people who backed it up, only made it through the "Ds". But again, that is inconsistent with the fact that the inaccessible songs' titles were uploaded to the new I Tunes library.
    I am totally stumped. Is there any way to fix this? I am faced with losing half my library.

    CAn anyone tell me how to get out of this iphone recovery? thanks!!

  • IPhoto "hangs" when Loading Library

    I'm having an issue with iPhoto, where, when I launch it, the app appears to open, but in the middle, where the photos are normally displayed, it hangs up saying "loading library", with the spinning gray cog wheel.
    No photos ever load, yet the program never crashes. It just stays in this state.
    I have opened iPhoto on a test users account, although none of my photos were present, but the app opened right up, leaving me thinking it's related to my normal user account.
    I have tried trashing the iphoto plist preference from my user preferences folder, but that did nothing. Same thing happens...
    iPhoto is version 5.0.4, and I'm running OS 10.4.11
    Any ideas? Thanks in advance...

    Jim,
    Another test - create a new library in your regular user account and see if it works. Hold the Option key as you launch iPhoto, select "Create Library". Give it a different name so you don't overwrite your current library. Does a new, empty library open? Import some test photos and see if it works. If so...
    It sounds like the database in your library is damaged beyond repair. Do you have an up-to-date backup? If not, you can try rebuilding the library with iPhoto Library Manager. It sometimes is successful when iPhoto's rebuild fails. Also, it creates a new library for the rebuild, so if it doesn't work you can just trash the new library with no harm done.
    If iPLM can't rebuild the library, then you may have to start over with a new library. You can follow the steps under "Manual Rebuild" in the Apple article referenced above. Before you do, I recommend you read lori_diloreto's post in this thread: http://discussions.apple.com/thread.jspa?messageID=1853164. She describes an alternate (better) way to repopulate your library, and she details what you should expect if you follow her instructions.
    Regards.

  • IPhoto 11 and 10.8.2 Hangs when loading library

    Ok..  I have just done my 4th clean install of Mountain Lion in the last 3 months.  Due to issues I've manually restored my iPhoto, iTunes, iMovie and Garageband content back to my new clean system and then opened the above mentioned programs.
    The problem is that iPhoto will not get past the opening after I choose the iPhoto library.
    My test account will open a blank iPhoto library.  But the main user account just hangs when loading the library.
    So far I've done the following.
    Launched with Command and Option and rebuilt the library and used the iphoto library 3rd party tool to rebuild the library.
    I've cleaned disk permissions.
    I've run Onyx and cleaned the entire system.
    I've trashed iPhoto and reinstalled iPhoto from the iPhoto 11 disk and then updated through the App store.
    What else can I try?  My iPhoto library is 54 Gigs and is all my digital photos of my kids since they were born 10 years ago.

    One simple thing you can try is Try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
    User/Home/Library/Caches/com.apple.iPhoto folder (Snow Leopard and Earlier).
    or with Lion and Mt. Lion from the User/Library/Containers/com.apple.iPhoto/
    Data/Library/Caches/com.apple.iPhoto folder
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    NOTE 2:  In Lion and Mountain Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    OT

  • Premiere hangs randomly when loading media from Canon 5D Mark III

    Premiere 5.5.0 hangs when loading media. When I drag like 20 files from explorer to Premiere, it loads some files, but at a random point it stops loading and freezes. I loaded every file manually by using ctrl-I within Premiere and saving regularly. After loading a random number of files (anywhere between 1 and 7) it freezes. I managed to get all the files into the project. Now when I try to open the project, it freezes randomly while loading the media. I copied the project and when I open the new one, it opens normal and asks where the media is. When I locate it... same problem, anywhere during loading it might freeze. When I cancel it, I can manually link every media file back, with the random risk of freezing.
    I reinstalled Quicktime without any improvement.
    I reinstalled Premiere without improvement.
    In old projects sometimes random media-files are not linked. Sometimes I can link them succefully. Sometimes it freezes when I try to link them.
    As far as I can tell this only happens to .mov files and not other types of media-files.
    Sometimes when I have been working on a project succesfully, Premiere still freezes when I close it.
    UPDATE
    I found out that this only concerned movies from my Canon 5d Mark III. I searched if other people had the same problem and found this thread: http://forums.creativecow.net/thread/3/923736
    The solution is to rename the extensions from .mov into .mpg.
    This solves the issue...

    danielschweinert wrote:
    Does somebody else has this problem?
    Yup: I heard about it just today, in fact.  An FCP user was trying to get Cinema Tools to conform 24fps footage from a Mk II and Mk III to 25.  No problems with the Mk II footage, but no luck with the Mk III footage.
    Now, it could be just coincidence.  But if you don't believe in coincidence, you might think that there's something screwy with Canon's new codecs for the Mk III.  "Screwy" is a highly technical term, by the way.

  • How to load images when loading application from Jar

    Hi,
    my program runs fine and all the images load from within Netbeans but the images dont load when I run the application from the executable Jar I created.
    In netbeans I used:
    Image image = Toolkit.getDefaultToolkit().getImage("images/fractions/image1.png");This works when run from netbeans but not from the Jar file.
    I created the Jar file using Netbeans Clean and Build function. Should this include the image files (which are located in an image folder 1 directory below the src folder were the .java files are located) or do I have to somehow explicitly say that the Jar should contain the images? or is there another reason the images aren't loading?
    Any help appreciated

    Hi,
    my program runs fine and all the images load from
    within Netbeans but the images dont load when I run
    the application from the executable Jar I created.
    In netbeans I used:
    Image image =
    Toolkit.getDefaultToolkit().getImage("images/fractions
    /image1.png");
    You should be use the getImage() method that takes a URL as a parameter and use the getResource() method of the class to get the URL to the Image:
    URL imageURL = getClass().getResource("images/fractions/image1.png");
    Image image = Toolkit.getDefaultToolkit().getImage(imageURL);See:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/icon.html#getresource
    Jim S.

  • Jar file - trying to load audio from within it

    I am writing a Game using NetBeans. All works fine when run from within NetBeans, but problems occur when run from a JAR executable.
    The Audio files are not loading. I had a Similar problem with the Images, but resolved it with getResources() etc.
    Any help would be much appreciated, and will post my game when its finished, horray
         * Loads a sequence from the file system. Returns null if
         * an error occurs.
        public Sequence getSequence(String filename)
            try
                return getSequence( new FileInputStream(filename));
            catch (IOException ex)
                ex.printStackTrace();
                return null;
         * Loads a sequence from an input stream. Returns null if
         * an error occurs.
        public Sequence getSequence(InputStream is)
            try
                if (!is.markSupported())
                    is = new BufferedInputStream(is);
                Sequence s = MidiSystem.getSequence(is);
                is.close();
                return s;
            catch (InvalidMidiDataException ex)
                ex.printStackTrace();
                return null;
            catch (IOException ex)
                ex.printStackTrace();
                return null;
        }

    new FileInputStream(filename))That only works for files. Resources in JARs are not files. You should always (when possible) use getClass().getResourceAsStream() to open streams on resources, loading them from the classpath -- regardless of whether your app is a bunch of loose files or in a JAR.

  • Aperture stuck when loading library

    I have a 56 GB aperture file that is not loading. <YIKES!> When I start aperture, the activity window says 'loading '<project>' where project is the last item I worked on. Then it stays there spinning.
    The library looks ok, I can see the contents. I rebooted my iMac. Other aperture libraries load ok.
    Aperture version 2.12
    iMac 1.83 intel core duo
    Any suggestions?

    rebuild the library and see if things are ok afterwards. to do this, press alt+command upon starting aperture and choose rebuild library from the options. this might take a while.
    j

Maybe you are looking for

  • HT2305 I am currently using a PC and it wont update which means the itunes I am using on my comuter is not up to date. How can I update it? do I have to uninstall and install it again?

    Today when I recieved my new phone I realized I needed to back the older one up so I tried and failed when my computer said that my Itunes was out of date so I went on itunes to find out that I have no idea how to just update itunes with out uninstal

  • Target Cost in process order

    Dear All,   I have activated the version 0 only and the valuation variant for the actual cost has been assigned as plan price for the period for both of variants of plan and actual.   when the order confirmed the actual cost is alone gets updated the

  • Problem parsing configuration/hibernate.cfg.xml

    I am trying to integrate struts with hibernate. I have created a plug-in for that and copied all the necessary jars & xmls to the classpath. I am providing the full stack trace, can any one say what could be the problem net.sf.hibernate.HibernateExce

  • Elements 10 and Lion OS

    Anybody using Elements Organizer/Photoshop 10 on a Mac running Lion? I have a mid 2009 MBP running Lion OS. I purchased Elements Premier 10 from Amazon. I have installed the software. My computer locks up to the point that I have to do a force quit e

  • JOptionPane Confusion!

    Hi, Im having a real difficult time with JOptionPanes! Im still a newbie to Swing and I just cant seem to get my head around how to make the JOptionPanes do what you want them to! I've read the tutorials and manuals but im still stuck. Basically, I h