Eclipse Community Forums Forum Search:

Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to get both SWT and my own native libraries in Eclipse Run...
How to get both SWT and my own native libraries in Eclipse Run... Wed, 11 January 2006 22:15
 Kenneth Evans, Jr.Messages: 77Registered: July 2009 Member
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:

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 #466691 is a reply to message #466604] Fri, 13 January 2006 14:56
 Veronika IrvineMessages: 1272Registered: 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>

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:

"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:
>
> 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: 77Registered: 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
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
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466696 is a reply to message #466691] Fri, 13 January 2006 18:33
 Sanjay ChaudhuriMessages: 19Registered: July 2009 Junior Member
Some time back there were few steps given to be able to run the application also as Java Application, by you.

This works great within the Eclipse environment but I could never really figure out, how to use this trick in a complete standalone windows environment, using the created configuration.

http://dev.eclipse.org/mhonarc/lists/platform-dev/msg00619.h tml
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466698 is a reply to message #466694] Fri, 13 January 2006 18:58
 Paul WebsterMessages: 6859Registered: July 2009 Location: Ottawa Senior Member
If you add the native libraries as part of configuring your plugin, your
like it automagically takes care of SWT).

You might want to ask this question in eclipse.platform or
eclipse.platform.rcp

Later,
PW
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466701 is a reply to message #466691] Fri, 13 January 2006 19:27
 Kenneth Evans, Jr.Messages: 77Registered: July 2009 Member
Veronika,

downloaded it to c:\swt. I then changed the Java Build Path | Libraries to
include the jar from c:\swt and removed the Standard Widget Toolkit (SWT)
libraries.

It then cannot find JFace, since that is not in the SWT download. (I
haven't got as far as handling the DLLs, yet.)

I cannot follow the rest of your instructions, nor also those in the
reference mentioned in the previous reply
( http://dev.eclipse.org/mhonarc/lists/platform-dev/msg00619.h tml). Some
explanation of why you do those steps and what you are trying to accomplish
would help.

Thanks,

-Ken
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466702 is a reply to message #466701] Fri, 13 January 2006 21:15
 Sanjay ChaudhuriMessages: 19Registered: July 2009 Junior Member
There is yet another link I found, which may help

http://www.zikal.com/jface/JFace3_1.html
Re: How to get both SWT and my own native libraries in Eclipse Run... [message #466704 is a reply to message #466701] Fri, 13 January 2006 23:49
 Kenneth Evans, Jr.Messages: 77Registered: July 2009 Member
> It then cannot find JFace, since that is not in the SWT download. (I
> haven't got as far as handling the DLLs, yet.)

OK, I found org.eclipse.jface.text_3.1.1.jar and org.eclipse.jface_3.1.1.jar
in the Eclipse files and put them in c:\swt along with the SWT download, and
then added them to the Java Build Path for the project. It then works in
Eclipse with -Djava.library.path set to c:\swt and C:\path\to\my\dll. And
it seems straightforward (meaning I understand what I did ;-).

Note that I don't have a separate Eclipse SWT project. I don't do anything
to .classpath, which seems to be an Eclipse thing. And I don't use a long
path to some esoteric cache directory I didn't create.

I can also export the project and make it work outside Eclipse if the
classpath is set to include all the jar files and the PATH is set to include
c:\swt and C:\path\to\my\dll.

-Ken
 Previous Topic: Date Time picker proposed for 3.2 Next Topic: SWT.Modify and SWT.Verify event for Spinner
Goto Forum:

Current Time: Sat Jan 21 00:28:32 GMT 2017