How do I tell eclipse how to find the SWT native libraries [message #239696] |
Sun, 04 November 2007 11:55  |
Eclipse User |
|
|
|
Originally posted by: James.Watrous.MatrixOne.com
I am new to SWT and have only used the basics in Eclipse. I am working
on a Windows XP-Pro SP2 machine with Eclipse 3.2.1. I created my “Hello
World” program for SWT as follows:
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class hello {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello, World");
label.setBounds(shell.getClientArea());
shell.open();
while (!shell.isDisposed()){
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
I added the external jar file
“org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” from my
“eclipse/plugins” directory to the “Libraries” tab of the
“Project->Properties-> Java Build Path” Dialog. I did not add any JVM
arguments on the Run dialog.
The project now builds, but I get a “no swt-win32-3236 in
java.library.path” error at run time.
I then extracted all the .dlls from
“org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” (swt-win32-3236.dll,
swt-awt-win32-3236.dll, swt-gdip-win32-3236.dll, swt-wgl-win32-3236.dll)
and placed them in a new directory (c:\SWT_dlls) and added this path to
the “Native Library Location” element that appeared under the
“org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” object that was added
to the “Project->Properties-> Java Build Path->Libraries” tab above.
The program now runs.
Should I be extracting the dlls from the jar, or is there a way to run
with them still inside the SWT jar file? How does Eclipse find the SWT
native libraries?
|
|
|
|
Re: How do I tell eclipse how to find the SWT native libraries [message #239769 is a reply to message #239731] |
Mon, 05 November 2007 10:35   |
Eclipse User |
|
|
|
Originally posted by: James.Watrous.MatrixOne.com
Tom,
Thank you very much. That did solve the problem. Apparently SWT is doing
some magic if System.loadLibrary("swt-win32-xxxx") fails in the 3.3 version.
Tom Schindl wrote:
> Jim,
>
> You'd be better of use SWT from 3.3 because then SWT takes care itself
> to extract the .dlls and resolve them appropriately.
>
> Tom
>
> Jim Watrous schrieb:
>> I am new to SWT and have only used the basics in Eclipse. I am working
>> on a Windows XP-Pro SP2 machine with Eclipse 3.2.1. I created my
>> “Hello World” program for SWT as follows:
>>
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.widgets.Display;
>> import org.eclipse.swt.widgets.Label;
>> import org.eclipse.swt.widgets.Shell;
>>
>> public class hello {
>>
>> public static void main(String[] args) {
>> Display display = new Display();
>> Shell shell = new Shell(display);
>> Label label = new Label(shell, SWT.CENTER);
>> label.setText("Hello, World");
>> label.setBounds(shell.getClientArea());
>> shell.open();
>> while (!shell.isDisposed()){
>> if (!display.readAndDispatch()) {
>> display.sleep();
>> }
>> }
>> display.dispose();
>> }
>> }
>>
>> I added the external jar file
>> “org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” from my
>> “eclipse/plugins” directory to the “Libraries” tab of the
>> “Project->Properties-> Java Build Path” Dialog. I did not add any JVM
>> arguments on the Run dialog.
>>
>> The project now builds, but I get a “no swt-win32-3236 in
>> java.library.path” error at run time.
>>
>> I then extracted all the .dlls from
>> “org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” (swt-win32-3236.dll,
>> swt-awt-win32-3236.dll, swt-gdip-win32-3236.dll,
>> swt-wgl-win32-3236.dll) and placed them in a new directory
>> (c:\SWT_dlls) and added this path to the “Native Library Location”
>> element that appeared under the
>> “org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar” object that was
>> added to the “Project->Properties-> Java Build Path->Libraries” tab
>> above.
>>
>> The program now runs.
>>
>> Should I be extracting the dlls from the jar, or is there a way to run
>> with them still inside the SWT jar file? How does Eclipse find the SWT
>> native libraries?
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.07814 seconds