How to Use third-party packages in eclipse RCP

Source: Internet
Author: User

When we add jar directly to RCP, it cannot be used as an instance. You need to manually set some places to run properly.

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 and packaged it into a jar file.Program. This program is like this:
Code:
Package demo;
Public class Hello {
Public static string sayhello ()
{
Return "Hello, world ";
}
}
[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 normal project, add it to build path. See figure 2 below to open the build page of plugin. Have you noticed 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 (){
Iworkbenchwindowcycler extends ER = getwindowcycler ();
Aggreger. setinitialsize (new point (400,300 ));
Aggreger. setshowcoolbar (false );
Configurer. setshowstatusline (false );
Explorer. settitle (hello. sayhello ());
}
[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.

Reprinted from: http://hi.baidu.com/lingyu125/blog/item/5e870d16a723561fc93d6d53.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.