zoukankan      html  css  js  c++  java
  • 创建向导时为其添加path,指为jar添加到path里面

    @Override
    protected void execute(IProgressMonitor monitor) throws CoreException,
       InvocationTargetException, InterruptedException {
      super.execute(monitor);
      try {
       // 将工程转为java工程
       IJavaProject fCurrJProject = JavaCore.create(project);
       // 获得Classpath
       IClasspathEntry[] fEntries = fCurrJProject.getRawClasspath();
       ArrayList<IClasspathEntry> newEntries = new ArrayList(
         fEntries.length + 1);
       for (int i = 0; i < fEntries.length; i++) {
        IClasspathEntry curr = fEntries;
        newEntries.add(curr);
       }
       // 将设置为源目录的文件夹
       IPath myLib1 = fCurrJProject.getProject().getFullPath().append("libs/freemarker.jar");
       IClasspathEntry myNewEntry1 = JavaCore.newLibraryEntry(myLib1, null, null, true);//这里使用的是newLibraryEntry 创建一个lib,这个会直接向.classpath写入一个lib库配置
       newEntries.add(myNewEntry1);
       
       IPath myLib2 = fCurrJProject.getProject().getFullPath().append("libs/log4j-1.2.13.jar");
       IClasspathEntry myNewEntry2 = JavaCore.newLibraryEntry(myLib2, null, null, true);//这里使用的是newLibraryEntry 创建一个lib,这个会直接向.classpath写入一个lib库配置
       newEntries.add(myNewEntry2);
       fEntries = (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]);
       // 把新的Classpath付给工程
       fCurrJProject.setRawClasspath(fEntries, new SubProgressMonitor(monitor, 2));
       
       //创建工程
       create();
      } finally {
       monitor.done();
      }
    }

  • 相关阅读:
    JavaScript基础语法及字符串相关方法(1)
    matplotlib实现三维柱状图
    前端入门CSS(3)
    博客页面练习
    前端入门CSS(2)
    前端入门CSS(1)
    前端入门html(表单)
    Longest Palindromic Substring
    Wildcard Matching
    Spiral Matrix II
  • 原文地址:https://www.cnblogs.com/eclipsetech/p/8626992.html
Copyright © 2011-2022 走看看