1.环境
eclipse版本:3.7.2
java版本:1.6.0_45
2. jar包如何调用
2.1 导入jar包
- 创建好项目后,进入项目后,创建libs文件夹,将jar包放入libs文件夹内;
- 选中项目,点击Runtime->Add选项,添加libs里的jar包;
2.2 项目配置
当jar包导入成功后,对此项目进行配置。
-
选中Build,将libs目录下所需要的jar包勾选上;
-
添加成功后,点击build.properties,可以看到我们引入的jar包;
- 点击MANIFEST.MF选项,Bundle-ClassPath参数下也显示引入的jar包
2.3 运行项目
- 选中项目运行;
- 运行时会自动又启动一个eclipse,点击类似eclipse的图标,可以看到有会有弹框,原来的eclipse项目运行控制台下也会打印调用jar里的方法返回的值。
3.问题
3.1 VM arguments选项下的参数后是存到哪个文件里了?
- Run->Run Configurations下的Arguments->VM arguments参数
- 使用工具监测进程,可以看到在项目存在的
D:\workspace\.metadata\.plugins\org.eclipse.debug.core\.launches
目录下Eclipse Application.launch文件
- 打开该文件可以看到,在org.eclipse.jdt.launching.VM_ARGUMENTS参数下,value的值就是配置的参数。
3.2 org.eclipse.help.IContext2错误如何解决?
出现该错误表示的是缺少依赖的jar
Caused by: java.lang.ClassNotFoundException: org.eclipse.help.IContext2
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 61 more
在eclipse安装目录的plugin目录下查找org.eclipse.help,将org.eclipse.help_3.5.100.v20110426.jar使用jd-gui工具查看,可以看到IContext2的类
所以将该jar包放入到项目中的libs目录下,引用即可。