• 创建向导时为其添加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();
      }
    }

  • 相关阅读:
    Threading in C# Learining
    win7 设置IIS
    Aforge视频采集
    C# 删除文件夹下的所有文件
    C# Timer实现实时监听
    Java中堆内存和栈内存详解
    彻底掌握 AQS
    四种线程同步/互斥方式小结
    CyclicBarrier可重用的循环栅栏
    答疑解惑之ExecutorService——shutdown方法和awaitTermination方法使用
  • 原文地址:https://www.cnblogs.com/eclipsetech/p/8626992.html
Copyright © 2020-2023  润新知