< Day Day Up > |
Recipe 8.4 Launching an SWT Application8.4.1 ProblemYou want to launch your SWT application. 8.4.2 SolutionYou need to tell the JVM where to find the Java Native Interface (JNI) code support for SWT when launching an SWT application. Here's the argument you supply when you run an SWT application (as before, HOMEDIR is the directory in which you installed Eclipse, and you should update these paths to match your version of Eclipse. For example, 2.1.2 should become 2.1.3 or some other version number):
8.4.3 DiscussionEven after you've compiled as SWT application, you still need to complete another step before you're ready to roll. You have to tell the JVM where to find the native code support for SWT with an argument to the JVM. To launch the SWT application we've been developing in the previous two recipes, select the class you want to run, FirstSWTClass, in the Package Explorer, and select Run Run to set up a launch configuration. In the Launch Configurations dialog, select Java Application, and click the New button. The Name, Project, and Main class boxes should be filled in automatically; if they aren't, fill them in. Then click the Arguments tab. In the "VM arguments" box, enter the JVM argument as shown earlier (see Figure 8-3). Figure 8-3. Setting up an SWT launch configurationThen click the Apply button, followed by the Run button. You should see this new example at work, as shown in Figure 8-4. Figure 8-4. Running an SWT applicationCongratulations—you're an SWT developer. 8.4.4 See AlsoRecipe 8.2 on creating an SWT application; Recipe 8.3 on setting Eclipse's build path to use SWT; Chapter 7 of Eclipse (O'Reilly). |
< Day Day Up > |