`
feng88724
  • 浏览: 171263 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

在Eclipse插件项目中引用第三方JAR包 空指针异常解决

阅读更多
I often get the question "How to add a third party JAR-file to my Eclipse plugin". It is not that tricky, but neither that obvious. Two solutions has been posted on the Eclipse newslists, but it can be quite hard to find it as the sheer number of posts is overhelming.

Here is two ways of doing it:
1. Turn the JAR-file(s) into plugin(s)
This is probably the simplest solution, but maybe not always achieving the desired granularity though. "Use New" -> "Project" -> "Plug-in Development" -> "Plug-in from existing JAR Archive". That will turn the JAR-file into a single JAR-plugin. Check that all required packages are re-exported.

2. Include the JAR-file(s) in the plugin in question:



Use the "Import" -> "File System" to import the JAR-file(s) into your plugin project. E.g. '/lib' directory

Then use "Add..." to add the JAR-file(s) to the classpath section of the Manifest/plugin.xml runtime tab.

Press "New..." to add "." library back to the the classpath (without quotes).

Check that the binary build exports the new JAR-file(s) on the Build tab.

Press save, important for the changes to come through.

Select the project in question in the package explorer view, right click and select "PDE Tools" -> "Update classpath". This will add the newly added JAR-file(s) to the project´s classpath.
When you are in the process of exporting the plugin make shure you do not package the plugin as "individual JAR archives", Eclipse cannot load JARs from within JARs, yet.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
   id="colimas_plugin"
   name="Colimas_plugin Plug-in"
   version="1.0.0"
   provider-name="nova"
   class="colimas_plugin.Colimas_pluginPlugin">

   <runtime>
      <library name="colimas_plugin.jar">
         <export name="*"/>
      </library>
      <library name="lib/activation.jar">
         <export name="*"/>
      </library>
      <library name="lib/axis.jar">
         <export name="*"/>
      </library>
      <library name="lib/commons-beanutils.jar">
         <export name="*"/>
      </library>
      <library name="lib/commons-discovery-0.2.jar">
         <export name="*"/>
      </library>
      <library name="lib/commons-logging-1.0.4.jar">
         <export name="*"/>
      </library>
      <library name="lib/jaxrpc.jar">
         <export name="*"/>
      </library>
      <library name="lib/xalan.jar">
         <export name="*"/>
      </library>
      <library name="lib/xerces.jar">
         <export name="*"/>
      </library>
      <library name="lib/saaj.jar">
         <export name="*"/>
      </library>
      <library name="lib/mail.jar">
         <export name="*"/>
      </library>
   </runtime>

   <requires>
      <import plugin="org.eclipse.ui"/>
      <import plugin="org.eclipse.core.runtime"/>
   </requires>

   <extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            label="Sample Action Set"
            visible="true"
            id="colimas_plugin.actionSet">
         <menu
               label="Sample &amp;Menu"
               id="sampleMenu">
            <separator
                  name="sampleGroup">
            </separator>
         </menu>
         <action
               label="&amp;Sample Action"
               icon="icons/sample.gif"
               class="colimas_plugin.actions.SampleAction"
               tooltip="Hello, Eclipse world"
               menubarPath="sampleMenu/sampleGroup"
               toolbarPath="sampleGroup"
               id="colimas_plugin.actions.SampleAction">
         </action>
      </actionSet>
   </extension>

</plugin>




以上是本人转载的他人的文章,最后发现根本不需要上述操作,上述操作根据没用

具体方法参见附件中的PDF文档。很详细
  • rcp.zip (664.7 KB)
  • 下载次数: 397
分享到:
评论

相关推荐

    Jar打包(解决eclipse无法打包含有第三方架包问题)

    然而,Eclipse IDE在默认情况下,对于包含第三方库的项目打包时可能会遇到问题,因为它并不自动将这些依赖的库文件包含进生成的JAR中。针对这一问题,我们可以采用一种称为"fat jar"的打包方式来解决。 "Fat jar"...

    eclipse导出第三方jar包插件fatjar

    - **Libraries**: 这是最重要的部分,你需要添加所有项目依赖的第三方JAR包。点击“Add External JARs…”或“Add JARs…”,选择项目中引用的库文件。 5. 完成上述配置后,点击“Finish”开始导出过程。Eclipse会...

    eclipse查看第三方jar包源码

    1.将net.sf.jadclipse_3.3.0.jar拷贝到eclipse的plugins目录下 2.再删除eclipse的configuration目录下org.eclipse.update文件 3.重启eclipse,点击菜单栏中File-&gt;Restart 4.下载jad的可执行文件,解压后放在某一磁盘...

    eclipse 打包 jar 碰到的问题(包含第三方包)

    总之,打包包含第三方库的Java项目在Eclipse中可以通过多种方式进行,关键在于理解项目结构、类加载机制和构建工具的使用。通过上述方法,你可以成功地解决“eclipse 打包 jar 碰到的问题(包含第三方包)”。

    打包第三方Jar插件

    确保第三方jar包在构建路径中,才能在编译和运行时正确引用其类和方法。 3. **Eclipse与MyEclipse的类加载机制** - Eclipse和MyEclipse使用OSGi(Open Services Gateway Initiative)框架来管理插件和类加载。OSGi...

    eclipse 第三方jar包配置.txt

    eclipse 第三方jar包配置.txt ,不使用eclipse自带的buildpath功能!

    java项目中去掉多余的jar包(三个Eclipse插件),有操作图示

    三个Eclipse插件可以去掉多余的java项目中jar包,有操作图示。

    eclipse打包jar插件

    标题中的"eclipse打包jar插件"指的是用于Eclipse的第三方插件,这些插件可以更方便地帮助开发者打包他们的Java项目为JAR格式。通常,这些插件会提供图形化的用户界面,使得设置和打包过程更为直观和高效。 描述中...

    eclipse查看jar包文件

    - `NOTICE`:一些开源项目会提供此文件,列出项目中使用到的第三方库以及它们的版权信息。 - `site.xml`:这可能是Eclipse插件的更新站点配置文件,描述了插件的元数据,包括名称、版本和描述等。 - `plugins` 和...

    eclipse查看第三方jar包源码(内附工具及详细使用教程).rar

    当运行引用了第三方jar包项目时,突然报出了jar包中的某个类的某一行出现异常。我们想看一下这个class文件的代码时,经常出现无法查看的情景,可使用JadClipse + net.sf.jadclipse_3.3.0.jar对jar包进行反编译,具体...

    Fatjar打包第三方包

    本篇文章将详细解释如何使用Fatjar来打包包含第三方jar包的插件,并在MyEclipse和Eclipse中进行操作。 首先,理解Fatjar的基本概念。Fatjar,又称为“胖Jar”,指的是将所有依赖库(包括第三方jar包)一起打包到...

    eclipse打jar包插件fatjar_0.0.32

    fatjar是一个打包包含第三方jar包的Eclipe插件。 解压后、将其中的jar包放入....\eclipse\plugins目录下,重启Eclipse, 右键项目 点击“Build fat jar”

    eclipse 的jar插件,可以快速制作jar包

    在Eclipse中,制作JAR(Java Archive)文件是一项常见的任务,这通常是为了打包和分发Java项目,或者为了创建可执行的Java程序。Eclipse的jar插件就是为了解决这个问题而设计的,它简化了这个过程,使得开发者能够...

    eclipse离线插件compiler反编译jar包进行debug调试

    在IT行业中,开发人员经常会遇到需要对已有的jar包或class文件进行反编译和调试的情况,以便理解其内部逻辑或修复bug。Eclipse作为一款流行的Java集成开发环境(IDE),提供了丰富的插件支持,使得这个过程变得相对...

    jarsearch-eclipse查询jar中class插件

    "jarsearch-eclipse查询jar中class插件"是一款专为Eclipse集成开发环境设计的实用工具,它极大地提升了开发者在处理Java项目时查找类文件的效率。这款插件能够快速、方便地在jar包或war包内部搜索特定的class文件,...

    eclipse查看jar源码插件,亲测可用

    本篇文章将详细讲解如何在Eclipse中安装和使用查看jar源码的插件,以及亲测有效的步骤。 首先,我们要解决的问题是如何在Eclipse中查看jar源码。默认情况下,Eclipse可能无法直接显示这些源代码。这时,我们就需要...

    eclipse查看jar包class文件源码插件,jar包反编译查看工具

    在IT行业中,开发人员经常需要对已编译的.jar文件进行反编译,以便查看其中的源代码。这是因为有时我们可能需要理解别人...在实际工作中,这些工具和方法能显著提高开发效率,尤其是在处理第三方库或者研究现有代码时。

    使用eclipse查看jar包的工具

    eclipse查看jar包源码工具:在Eclipse查看开发包jar源码的方法如下: 1.选择项目,右键中单击【Properties】 2.【Java Build Path】-【Configure Build Path】-【Libraries】,在下面找到如:Guava-r09.jar包,...

    Eclipse打包成JAR包读取外部JAR包和外部配置文件

    在Java开发过程中,Eclipse是一款常用的集成开发环境(IDE),它提供...通过以上步骤,你就可以成功地在Eclipse中打包项目,并实现对外部JAR包和配置文件的正确引用。这不仅有助于项目部署,也有利于后续的维护和升级。

Global site tag (gtag.js) - Google Analytics