[转载]Eclipse插件及RCP开发中的第三方库的设置

很多人在开发RCP时,发现开发时都没问题,但导出成包时却报找不到第三方库中类的错误。主要原因就是没有将第三方库配置好。现在我给出一个实现项目的配置为示例,以供参考。 原文出处:http://www.eclipseworld.org/bbs/read.php?tid=1133   环境:Eclipse3.2M3 一个RCP的实际项目 

一、最关键的就是plugin.xml和MANIFEST.MF   
所有界面上的最后操作,结果都是保存在这两个文件中。注意:“.classpath”文件只是开发时对引用第三库有用,打包发行之后它的作用就没有了,还得靠plugin.xml和MANIFEST.MF。
1、plugin.xml文件
<?xml version="1.0" encoding="GB2312"?>
<?eclipse version="3.0"?>
<plugin>
   <extension
         id="AdminConsole"
         point="org.eclipse.core.runtime.applications">
        <application>
            <run class="com.wxxr.management.admin.console.AdminConsole"/>
        </application>
   </extension>
 
   <extension id="AdminConsole" point="org.eclipse.core.runtime.products">
  <product name="%productName" application="com.wxxr.management.admin.console.AdminConsole">
   <property name="appName" value="%swtAppName"/>
   <property name="windowImages" value="icons/eclipse.gif,icons/eclipse32.gif"/>
   <property name="aboutText" value="%aboutText"/>
   <property name="aboutImage" value="icons/eclipse_lg.gif"/>
   <property name="windowImages" value="icons/alt16.gif,icons/eclipse.gif"/>
  </product>
   </extension>
  
   <extension
      point="org.eclipse.ui.perspectives">
      <perspective
            class="com.wxxr.management.admin.console.monitor.MonitorPerspective"
            name="%perspectiveName"
            id="com.wxxr.management.admin.console.monitor.MonitorPerspective"/>
      <perspective
            class="com.wxxr.management.admin.console.configure.ConfigurePerspective"
            name="%configurePerspectiveName"
            id="com.wxxr.management.admin.console.configure.ConfigurePerspective"/>
      <perspective
            class="com.wxxr.management.admin.console.jmx.JMXPerspective"
            name="%jmxPerspectiveName"
            id="com.wxxr.management.admin.console.jmx.JMXPerspective"/>
   </extension>
 <extension
   point="org.eclipse.ui.editors">
   <editor
   name="事件列表"
   icon="icons/alt16.gif"
   class="com.wxxr.management.admin.console.log.ui.LogEditor"
   id="com.wxxr.management.admin.console.log.ui.LogEditor">
   </editor>
   <editor
   name="地图"
   icon="icons/map_view.gif"
   class="com.wxxr.management.admin.console.map.MapEditor"
   id="com.wxxr.management.admin.console.map.MapEditor">
   </editor>
 </extension>
   <extension
         point="org.eclipse.ui.views">
      <category
            id="com.wxxr.management.admin.console.monitor.view"
            name="%views.category.name"/>
      <view
            id="com.wxxr.management.admin.console.navigator.ui.StationExploreView"
            name="工作站"
            icon="icons/eclipse.gif"
            class="com.wxxr.management.admin.console.navigator.ui.StationExploreView"
            category="com.wxxr.management.admin.console.monitor.view"/>
      <view
            name="事件细节"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.monitor.view"
            class="com.wxxr.management.admin.console.monitor.eventview.EventDetailView"
            id="com.wxxr.management.admin.console.monitor.eventview.EventDetailView" />
      <view
            name="事件统计"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.monitor.view"
            class="com.wxxr.management.admin.console.monitor.view.SystemEventStatisticsView"
            id="com.wxxr.management.admin.console.monitor.view.SystemEventStatisticsView" />
      <view
            name="紧急事件处理"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.monitor.view"
            class="com.wxxr.management.admin.console.emergency.ui.EmergencyEventReceiverView"
            id="com.wxxr.management.admin.console.emergency.ui.EmergencyEventReceiverView" />
      <category
            id="com.wxxr.management.admin.console.jmx.view"
            name="%views.category.name"/>
      <view
            name="JMX Connections"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.jmx.view"
            class="com.wxxr.management.admin.console.jmx.ui.JMXExploreView"
            id="com.wxxr.management.admin.console.jmx.ui.JMXExploreView" />
      <view
            name="JMX Attributes View"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.jmx.view"
            class="com.wxxr.management.admin.console.jmx.ui.AttributesView"
            id="com.wxxr.management.admin.console.jmx.ui.AttributesView" />
      <view
            name="JMX Operations View"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.jmx.view"
            class="com.wxxr.management.admin.console.jmx.ui.OperationsView"
            id="com.wxxr.management.admin.console.jmx.ui.OperationsView" />
      <view
            name="JMX MBean View"
            icon="icons/eclipse.gif"
            category="com.wxxr.management.admin.console.jmx.view"
            class="com.wxxr.management.admin.console.jmx.ui.MBeanView"
            id="com.wxxr.management.admin.console.jmx.ui.MBeanView" />
   </extension>
   <extension
         id="AdminConsole"
         point="org.eclipse.core.runtime.products">
      <product
            application="com.wxxr.management.admin.console.AdminConsole"
            name="AdminConsole"/>
   </extension>
  
</plugin>
  2、META-INF\MANIFEST.MF文件
    注意:(1)这里require-bundle定义了项目依赖的插件。
(2)Bundle-ClassPath定义了引用的第三方库,别忘了把AdminConolse项目自己console.jar加进去,否则连自己项目里的类都会找不到。
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.wxxr.management.admin.console; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.wxxr.management.admin.console.AdminConsolePlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.gef,
 org.eclipse.ui.forms,
 org.eclipse.ui.console
Eclipse-AutoStart: true
Bundle-Vendor: %providerName
Bundle-ClassPath: console.jar,
 lib/commons-codec-1.3.jar,
 lib/jboss.jar,
 lib/jbossall-client.jar,
 lib/jboss-jmx.jar,
 lib/jboss-system.jar,
 lib/log4j-1.2.8.jar,
 lib/wxxr-common-1.0-b1.jar,
 lib/wxxr-common-jboss-1.0-b1.jar,
 lib/wxxr-db-persistence-1.0-b1.jar,
 lib/wxxr-jboss-controller-1.0-b1.jar,
 lib/wxxr-jboss-workstation-1.0-b1.jar,
 lib/wxxr-remoting-1.0-b1.jar,
 lib/wxxr-security-1.0-b1.jar,
 lib/xerces-2.6.2.jar,
 lib/xmlParserAPIs-2.2.1.jar,
 lib/xmlrpc-2.0.jar
 3、build.properties文件
这个文件主要是用Eclipse导出包的时候用。
source.console.jar = src/
output.console.jar = bin/
bin.includes = plugin.xml,\
               *.jar,\
               console.jar, \
               plugin.properties
              
pluginName = Admin Console Plug-in
providerName = WXXR.com.cn
perspectiveName = Admin Console
configurePerspectiveName= Configure
jmxPerspectiveName= JMX Console
              
jars.extra.classpath = lib/commons-codec-1.3.jar,\
                       lib/jboss.jar,\
                       lib/jbossall-client.jar,\
                       lib/jboss-jmx.jar,\
                       lib/jboss-system.jar,\
                       lib/log4j-1.2.8.jar,\
                       lib/wxxr-common-1.0-b1.jar,\
                       lib/wxxr-common-jboss-1.0-b1.jar,\
                       lib/wxxr-db-persistence-1.0-b1.jar,\
                       lib/wxxr-jboss-controller-1.0-b1.jar,\
                       lib/wxxr-jboss-workstation-1.0-b1.jar,\
                       lib/wxxr-security-1.0-b1.jar,\
                       lib/wxxr-remoting-1.0-b1.jar,\
                       lib/xerces-2.6.2.jar,\
                       lib/xmlParserAPIs-2.2.1.jar,\
                       lib/xmlrpc-2.0.jar
4、plugin.properties,这个放一些上面几个文件用到的变量。
pluginName= WXXR Admin Console
providerName= wxxr.com.cn
 
productName= WXXR SMS Operation Platform
appName= WXXR Admin Console
perspectives.browser.name= WXXR Admin Console
views.category.name= WXXR Admin Console
views.browser.name= Browser
views.history.name= History
views.stationexplore.name= Stations
views.tasklist.name= Task List
views.loglist.name= Workstation Monitor
monitor.message.detail=Monitor Message Detail
monitor.message.statistics=????
 
swtAppName= AdminConsole
aboutText= WXXR Admin Console \n\n\
(c) Copyright WXXR Ltd. and others 2003, 2004.  All rights reserved.\n\
Visit http://www.wxxr.com.cn
 二、图形方式 有时直接编辑plugin.xml等文件容易出错(全角空格什么的),那么可以用图形编辑方式来,不过最后结果还是反映到plugin.xml等文件中的。我把plugin.xml打开,然后一个项一个项的把图截下来,以供大家参考。

posted on 2007-01-04 14:10 小牛小虾 阅读(703) 评论(1)  编辑  收藏

评论

# re: [转载]Eclipse插件及RCP开发中的第三方库的设置 2010-09-21 15:56 symons cone crusher

你还挺有自知之明的嘛,没有姚明高,没有华仔帅,哈哈  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2007年1月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

导航

统计

常用链接

留言簿(6)

随笔档案

文章档案

eclipse

搜索

最新评论

阅读排行榜

评论排行榜