Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 07e3850ec2d3b9bbf411ef94c5430cca210fd805 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <title>SWT Standalone Examples Setup</title>
</head>
<body>

<h2>SWT Standalone Examples Setup</h2>

<h3>Importing Example Source</h3>

<p>
*** In the following description, substitute the location in which you installed Eclipse for INSTALLDIR ***
</p>

<p>Import the example code and all its required resources into your workspace:</p>

<ol>
<li>Create a Java Project called "SWT Examples".
<li>Select the project "SWT Examples" in the Packages view.
<li>Select the File &rarr; Import menu.  Select Zip File. Click on Next.
<li>Locate the source zip file for the SWT examples.  For example:
	<ul>
    <li><b>win32: </b><code>INSTALLDIR\eclipse\plugins\org.eclipse.swt.examples_2.0.0\swtexamplessrc.zip</code>
    <li><b>*nix: </b><code>INSTALLDIR/eclipse/plugins/org.eclipse.swt.examples_2.0.0/swtexamplessrc.zip</code>
    </ul>
<li>Click on Finish.
<li>Select the File &rarr; Import menu. In the Import dialog, select Zip File. Click on Next.
<li>Locate the jar file for the SWT examples.  For example:
    <ul>
    <li><b>win32: </b><code>INSTALLDIR\eclipse\plugins\org.eclipse.swt.examples_2.0.0\swtexamples.jar</code>
    <li><b>*nix: </b><code>INSTALLDIR/eclipse/plugins/org.eclipse.swt.examples_2.0.0/swtexamples.jar</code>
    </ul>
<li>Expand the top level directory of the zip file (/). <b>Uncheck "org" and "META-INF"</b>.
<li>Click on Finish.
</ol>

<p>Now you need to compile the SWT examples.  In order to do this, you must add the SWT jar(s) to 
the compile path:</p>
<ol>
<li>Select the project "SWT Examples" in the Packages view and from the pop up menu select Properties.
<li>Select the Java Build Path item.
<li>Go to the Libraries tab.
<li>Click on the Add External JARS... button.
<li>Locate the swt jar for the platform on which you wish to run:<br>
    <ul>
    <li><b>win32: </b><code>INSTALLDIR\eclipse\plugins\org.eclipse.swt.win32_2.0.0\ws\win32\swt.jar</code>
    <li><b>gtk: </b><code>INSTALLDIR/eclipse/plugins/org.eclipse.swt.gtk_2.0.0/ws/gtk/swt.jar</code>
    <li><b>motif: </b><code>INSTALLDIR/eclipse/plugins/org.eclipse.swt.motif_2.0.0/ws/motif/swt.jar</code>
    <li><b>photon: </b><code>INSTALLDIR/eclipse/plugins/org.eclipse.swt.photon_2.0.0/ws/photon/swt.jar</code>
    </ul>
<li>Click on OK.
</ol>
<p><b>NOTE:</b> For some platforms (such as GTK), more than one jar is required to run SWT (on
GTK there is a swt.jar and a swt-pi.jar file).  In this case, all the required jars must 
be added to the class path.  This is done by repeating the steps above for each jar file.
All jar files are located in the same directory/folder.</p>

<p>At this point your SWT examples should be compiled without any errors.  Check the Task 
view for errors.  If you get an error like "<code>java.lang.Object</code> not found" it means 
you have not configured a JRE.  Go to the Window &rarr; Preferences dialog.  
Select Java &rarr; Installed JREs and ensure that a JRE is installed 
and that the path to the JRE is correct.</p>

<h3><a NAME="Run"></a>Running the Example</h3>

<p>Now you have to configure Eclipse to run the example.  This requires putting the SWT
JNI libraries on the library path so that the VM can find them:

<ol>
<li>Open the Java Perspective.
<li>In the Packages view, select the Main class that you want to run.  
    For example, the Main class for the Address Book example is 
    &nbsp;&nbsp;&nbsp;&nbsp;<code>org.eclipse.swt.examples.addressbook.AddressBook</code>.
<li>SelectRun &rarr; Run... from the main menu.  
<li>In the Launch Configurations dialog that appears, select Java Application and click 
    on the New button.
<li>Fill in the Name, Project and Main class fields according to the example you wish to run.
<li>Select the Arguments tab.  In the VM Arguements area specify the location of the SWT 
    library depending on your target platform as follows:
    <ul>
	<li><b>win32: </b><code>-Djava.library.path=INSTALLDIR\plugins\org.eclipse.swt.win32_2.0.0\os\win32\x86</code>
	<li><b>linux gtk: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.gtk_2.0.0/os/linux/x86</code>
	<li><b>linux motif: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.motif_2.0.0/os/linux/x86</code>
	<li><b>solaris motif: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.motif_2.0.0/os/solaris/sparc</code>
	<li><b>aix motif: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.motif_2.0.0/os/aix/ppc</code>
	<li><b>hpux motif: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.motif_2.0.0/os/hpux/PA_RISC</code>
	<li><b>photon qnx: </b><code>-Djava.library.path=INSTALLDIR/eclipse/plugins/org.eclipse.swt.photon_2.0.0/os/qnx/x86</code>
	</ul>
<li>Click on the Run button.
</ol>


<h3>Examples Overview</h3>
<p>
Consult the documentation of each individual example for the names of
its Main class and additional details.
</p>
<p>
The following examples are included in the <code>swtexamples.jar</code>:
</p>
<ul>
<li><a href="swt_addressbook_ex.html">Address Book</a>
<li><a href="swt_control_ex.html">Control Overview</a>
<li><a href="swt_fileviewer_ex.html">File Viewer</a>
<li><a href="swt_helloworld_ex.html">Hello World [1-5]</a>
<li><a href="swt_hoverhelp_ex.html">Hover Help</a>
<li><a href="swt_imageanalyzer_ex.html">Image Analyzer</a>
<li><a href="swt_javaviewer_ex.html">Java Viewer</a>
<li><a href="swt_layout_ex.html">Layout Overview</a>
<li><a href="swt_texteditor_ex.html">Text Editor</a>
</ul>

<p><br><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation 2000, 2002.  All Rights Reserved." BORDER=0 height=12 width=195></a>
</body>
</html>

Back to the top