Let's take a simple example to illustrate that this example uses the simplest template of eclipse RCP, namely hello, RCP that everyone has ever seen. The eclipse version I used is 3.2m2.
For ease of instruction, I wrote a Java file, packaged it into a jar, and then called it in the RCP program. This program is like this:
Code:
Package demo; </P> <p> public class Hello {<br/> Public static string sayhello () <br/>{< br/> return "Hello, world "; <br/>}< br/>
[Ctrl + A select all]
This is simple. Package and make it a hello. jar file. The specific process is omitted.
Next, we will create an RCP application. The specific process will be omitted. It is worth reminding you that the name of the RCP project should be in lower-case English, which may cause some problems, at least in the version I used.
Create a lib directory as the directory for storing third-party libraries. Copy the hello. jar file. See.
Figure 1
In the RCP project, you can add the jar to the class path in two ways. You can choose one of them:
In the RCP project, you can add the jar to the class path in two ways. You can choose one of them:
In the RCP project, you can add the jar to the class path in two ways. You can choose one of them:
- Like a common project, add it to build path. See figure 2 below.
- Open the build page of plugin and notice that there is an "extra classpath entries" at the bottom? After expansion, select Add jars to add the required jar, which has the same effect. See figure 3.
Figure 2
Figure 3
Here, I am saying "select one" means not to use both methods at the same time, otherwise the project will report an error.
After all the above work is done, it is still on the build page of the plugin, and the output directory of your program under the binary build on the left (bin in my project) check the directory where your jar is located (Lib in my project), so that the output will contain the compiled files and third-party libraries. Still refer to the third figure
Switch to the runtime page of plugin, and put the output directory of your program (bin in my program) in the classpath in the lower right corner) and all the jar files you want to include (my program contains lib/hello. jar. See Figure 4.
Figure 4
The next thing to do is to modify the program. Here I simply modify the program title, find the applicationworkbenchwindowadvisor class, and change prewindowopen to the following:
Code:
Public void prewindowopen () {<br/> iworkbenchwindowcycler extends ER = getwindowcycler (); <br/> cycler. setinitialsize (new point (400,300); <br/> cycler. setshowcoolbar (false); <br/> cycler. setshowstatusline (false); <br/> cycler. settitle (hello. sayhello (); <br/>}< br/>
[Ctrl + A select all]
This example is complete. After the product file is generated, the result is displayed after the export is generated. The process is also omitted.
After running, the title bar changes from "Hello, RCP" to "Hello, world". See figure 5.
Figure 5
Note: This article was originally published onEclipse community in China, Welcome to visit