|
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466691 is a reply to message #466604] |
Fri, 13 January 2006 14:56 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
It all depends on where the SWT you are running against comes from.
If you are using SWT from the plugin that is part of your Java IDE, then you
can use Run As SWT Application. This will find the SWT dlls for you. You
can find your own dll by setting -Djava.library.path+C:\path\to\my\dll in
the VM argments field of the launch configuration dialog (Run As -> SWT
Application ... brings up a dialog and you enter this is in the VM
arguements section).
Alternatively, you can use the SWT from the standalone SWT binary doaloads
(e.g. ). The you can just import the archive file as a project and the dll
path will be automatically set up by the following line in the classpath
file:
<classpathentry kind="src" path="Eclipse SWT PI/win32">
<attributes>
<attribute value="org.eclipse.swt.win32.win32.x86"
name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY "/>
</attributes>
</classpathentry>
(Note, you can add a similar line to your own classpath to export your dll
and then you will not need to modify the VM arguments for every launch).
Here is a link to the 3.1.1 version of the SWT standalone binary:
http://download.eclipse.org/eclipse/downloads/drops/R-3.1.1- 200509290840/index.php#swt
"Kenneth Evans" <evans@aps.anl.gov> wrote in message
news:dq4016$49b$1@utils.eclipse.org...
>I am having trouble getting an SWT program to find my own native libraries
> using Run... in Eclipse.
>
> If it were a Swing application running in Eclipse, the java.library.path
> would be my PATH, and it would find my libraries (and work).
>
> However, for an SWT application, Eclipse 3.11 makes the java.library.path
> be
> something like:
>
> ...\Work\.metadata\.plugins\org.eclipse.ve.java.core\.cache\ .libCache\-79227
> 5406
>
> and it changes each time, as well.
>
> It then cannot find my libraries. I assume this has something to do with
> extracting the .dll's from the jar files.
>
> How do I get around this and get my PATH to be part of the
> java.library.path
> and still get the SWT libraries. Presumably I could
> set -Djava.library.path, but I don't know what to set it to get the SWT
> libraries.
>
> Thanks,
>
> -Ken
>
>
|
|
|
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466694 is a reply to message #466691] |
Fri, 13 January 2006 17:53 |
Kenneth Evans, Jr. Messages: 77 Registered: July 2009 |
Member |
|
|
"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:dq8f3c$ai3$1@utils.eclipse.org...
> It all depends on where the SWT you are running against comes from.
>
> If you are using SWT from the plugin that is part of your Java IDE, then
you
> can use Run As SWT Application. This will find the SWT dlls for you. You
> can find your own dll by setting -Djava.library.path+C:\path\to\my\dll in
> the VM argments field of the launch configuration dialog (Run As -> SWT
> Application ... brings up a dialog and you enter this is in the VM
> arguements section).
>
Veronika,
Thanks for your reply. I am not at this time using the standalone SWT
binary downoads, so I will respond to the first part. I also no longer have
an SWT plug-in in my Workspace. It doesn't seem to be necessary and doesn't
seem advisable for an RCP application. It is enough to add SWT to the
project properties.
I have a program that uses either a JNI implementation or a Java
implementation of one part of it (not the SWT part). With the Java
implementation, it works fine and it finds the SWT DLLs as I described.
With the JNI implementation, it still finds the SWT DLLs but doesn't find
mine. If I set -Djava.library.path=C:\path\to\my\dll as you suggest, it no
longer finds the SWT DLLs (but it does find mine).
The bottom line is that your suggestion does not work. I have already tried
it.
Apparently Eclipse is setting the java.library.path to where it extracts the
DLLs from the jar. It is ignoring the fact that this destroys the default
behavior of using PATH for the java.library.path. I would consider this a
bug.
Since writing the original message, I have found that if I add the cache
directory (with the long name and number) that it normally uses
to -Djava.library.path along with C:\path\to\my\dll , then it works (so
far). This is rather tedious as I have to write code in the program to
print out what Eclipse used, then copy it to the Run... configuration, then
remove that code. I am not sure how the project will port to other
computers. I also have no idea when Eclipse will change the cache directory
(C:\Documents and Settings\evans\My
Documents\Eclipse\Work\.metadata\.plugins\org.eclipse.ve.jav a.core\.cache\.l
ibCache\-79227540, in my case).
BTW with "Run As SWT application" Eclipse uses yet another
java.library.path (as determined by printing it from the code). I also do
not get the dialog for the VM arguments you mention, but these can be
entered in the Run... configuration dialog.
Thanks again,
-Ken
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03560 seconds