• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configuring eclipse to use dll files at runtime

 
Swapnil Shroff
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How do i configure eclipse to use a dll file at runtime.

I have 2 dll files for example one.dll and two.dll

the two.dll is referred by dll one.dll

now i have put both files in jre\lib folder.

at runtime eclipse can find one.dll but gives error for two.dll.

any idea..any solutions..please advice.

thanks
 
Pavan Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried this, but this is what I think.
the dll files should be available on the classpath, when you run the program. One way to put these dll files on the classpath is to add the directory, in which the dll files exist, to the classpath.

You can do so by selecting project properties-- > Add Class Folder option.

Hope that helps,

Cnu,
 
Swapnil Shroff
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is not working

it takes only jar in classpath
 
Swapnil Shroff
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is not working

it takes only jar in classpath
 
Pavan Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swapnil, pay attention to the options you have when you open project propeties dialog. There are various options, if you choose to add jars or add external jars to the classpath, ofcourse it would let you add jar or zip files only.

You have to try add class Folder option, where in you can add a folder to your classpath and this folder can contain anything in it.

Hope that helps.

Cnu.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18108
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse is not a Microsoft Windows application. That is, there's no code in it that makes it substantially dependent on Windows instead of Linux.

DLL's are binary code libraries, and no Java program can access DLL's directly, including Eclipse. Instead, you have to wrap the DLL functions and/or data in JNI (Java Native Interface) Java classes. The JNI modules are generally written in C and compiled, and as part of the C code in the JNI module, you'd use the LoadLibrary call to load the DLL just like any other C program module would. Neither Eclipse nor the JVM ever see the DLL directly.

And, of course, any code you produce using JNI DLL-calling classes will only run on Microsoft Windows.
 
Swapnil Shroff
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes of course I am using JNI and loadlibrary to use DLL files. what i meant to say is that after doing all setting for JNI, my java program can find the immediately referencing DLL file if i put it under jre/lib folder but it doesn't find the DLL used by this dll.

we have entire configuration done for our environment in jbuilder now only thing is that we have to configure eclipse similarly so i think there must be some way in eclipse.

And, of course, any code you produce using JNI DLL-calling classes will only run on Microsoft Windows.


I am not sure about this but our application is developed for unix as well as windows users so i think it should work for UNIX also
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18108
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath has no relation to binary system library loading paths. Classpaths are used only to resolve requests for Java resources.

n a Windows app, there's a predefined set of places that the system DLL loader will attempt to load from (consult MSDN), plus you can force loading from places you designate. The docs on the LoadLibrary function were fairly clear and accurate last time I used them. Hopefully Microsoft hasn't messed them up.

DLLs do not exist in any Unix system. The equivalent construct is a dynamic Shared Object, which is usually created using the "ar" utility. These libraries have the file extension ".so". An ".so" isn't quite the same as a DLL, though the basic concepts are similar. For one thing, Unix has somewhat better support for maintaining multiple active library versions, though it also lacks one or 2 things that Windows DLLs have.

If you ARE producing an SO, the normal process is to include it in the library search path, as defined by an environment variable named something like SYSTEM_LOAD_LIBRARY - but my memory's not accurate on its exact name. You may also need to register the SO's directory location with system utility program.
 
Meena Nikode
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was also facing the problem while configuring dll in eclipse.

One way I tried is to put jars in classpath using add jars/external jars utility in project properties and all my jars as well dll I got selected to add the same. But ofcourse it would add jars/zip files only.

One option is to try keeping that dll in your <JDK>/jre/bin used in eclipse system library and was able to configure dll files at runtime , by placing dll in /jre/bin ..
 
Anuradha Rao
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Provide the path to your dll in the VM agrs in eclipse like this. It should work.

-Djava.library.path="{dll path}"
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always add the directory containing your DLL to the PATH (Linux translation: directory containing .so to LD_LIBRARY_PATH). Back when I was doing some development that required native calls to DLLs, I had a PATH entry specifically for the DLLs I was using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic