[SOLVED] DLL cannot be loaded from within Eclipse

Feature Requests, Comments, Bugs, and Suggestions on the JIntellitype Java API.

[SOLVED] DLL cannot be loaded from within Eclipse

Postby larsen » Fri Oct 19, 2012 5:00 pm

Hi,

I already spent hours trying to figure out what´s going on here, but I´m stuck. I read most of the other forums posts and have downloaded the jintellitype-example mentioned in one. I can start the example. I can delete the DLL from that directory and the example is still running fine as the DLL is also in "c:\windows\system32".

Though, when I start my own application in Eclipse, the DLL cannot be found and I can´t imagine any reason for it. This also used to work before. Then I have paused the development of my application for some months and besides installing Windows updates and a new Eclipse version, I think nothing has changed.

Error message is:
Code: Select all
Exception in thread "main" com.melloware.jintellitype.JIntellitypeException: Could not load JIntellitype.dll from local file system or from inside JAR


I can start my application outside of Eclipse. I have restarted Windows and Eclipse multiple times.
OS is Windows XP SP3, 32-bit. jintellitype 1.3.8.

I have used this to set the library location manually, but it didn´t work either:
Code: Select all
JIntellitype.setLibraryLocation(new File("C:\\WINDOWS\\system32\\JIntellitype.dll"));



Do you have any idea?

Lars
Last edited by larsen on Sat Oct 20, 2012 10:43 am, edited 1 time in total.
User avatar
larsen
 
Posts: 8
Joined: Thu Nov 17, 2011 11:00 am

Re: DLL cannot be loaded from within Eclipse

Postby Melloware » Sat Oct 20, 2012 7:25 am

Hmm this should work.

Did you try putting the DLL in the directory where Eclipse considers home? For example in JIntellitype it is in the root directory of the project where the .classpath and .project Eclipse files are and that is what Eclipse considers its "home directory" and the DLL should be found in there.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: DLL cannot be loaded from within Eclipse

Postby larsen » Sat Oct 20, 2012 8:30 am

I now tried the following additional locations:

- the root folder of the project containing .classpath and .project
- the folder bin/net/sf/opensoundboard where my main class is
- the lib folder where jintellitype-1.3.8.jar is

The jintellitype-example can use the DLL from system32. If I delete it there, the example won´t run, so it´s definitely using that file.

Still, I have no idea why it won´t run inside Eclipse.The JIntellitypeTester won´t run either in Eclipse.
User avatar
larsen
 
Posts: 8
Joined: Thu Nov 17, 2011 11:00 am

Re: DLL cannot be loaded from within Eclipse

Postby Melloware » Sat Oct 20, 2012 9:27 am

That is so strange. The very first call to System.loadLibrary() is a Java call to load any DLL named JIntellitype.dll found in the classpath which include the running directory and /system32 by default.

The API is explained here:

http://www.chilkatsoft.com/p/p_499.asp
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: DLL cannot be loaded from within Eclipse

Postby larsen » Sat Oct 20, 2012 10:42 am

Ok, after hours of searching I finally found the root problem.

I noticed that "java.library.path" is set to only "C:\Program Files\Java\jdk1.7.0_07\jre\lib". On another PC it contains amongst others the system32 folder and all the directories from the %PATH% environment variable. This explains why it doesn´t work and provides a workaround by setting it manually in the VM arguments via "-Djava.library.path=c:/windows/system32".

Though, I wanted to find out where the hell this comes from. I had already searched the Eclipse folder for that string "jdk1.7.0_07" and thought I had already done this for my project folder, too, but I didn´t. That could have saved me some time.

I found this for my user library:
Code: Select all
   <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFX">
      <attributes>
         <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:/Program Files/Java/jdk1.7.0_07/jre/lib"/>
      </attributes>
   </classpathentry>

And again after some hard thinking and checking the file´s history, I remembered that I had adapted the classpath to the new position of the JavaFX library. My error apparently was that I somehow (I think by accident) edited the "Native library location" and entered the string that can be seen above. Eclipse on the other hand apparently replaces the library path instead of adding that value, so that´s why it went wrong.

Solution: Fix the build path by removing the "Native library location" value from the user library.
User avatar
larsen
 
Posts: 8
Joined: Thu Nov 17, 2011 11:00 am

Re: [SOLVED] DLL cannot be loaded from within Eclipse

Postby Melloware » Sun Oct 21, 2012 6:16 am

Awesome! Thanks for posting your solution!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA


Return to JIntellitype

Who is online

Users browsing this forum: No registered users and 1 guest

cron