Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法解决此过程_Java_Jar - Fatal编程技术网

Java 无法解决此过程

Java 无法解决此过程,java,jar,Java,Jar,我正在尝试使用,但无法加载 当我尝试在Eclipse Kepler中打开示例中的以下文件时,Eclipse抱怨TIntProcedure无法解决: package net.sourceforge.jsi.examples; import gnu.trove.*; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import

我正在尝试使用,但无法加载

当我尝试在Eclipse Kepler中打开示例中的以下文件时,Eclipse抱怨
TIntProcedure
无法解决:

package net.sourceforge.jsi.examples;

import gnu.trove.*;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.infomatiq.jsi.Rectangle;
import com.infomatiq.jsi.SpatialIndex;
import com.infomatiq.jsi.rtree.RTree;

public class Contains {
  private static final Logger log = LoggerFactory.getLogger(Contains.class);

  public static void main(String[] args) {
    new Contains().run();
  }

  private void run() {
    // Create and initialize an rtree
    SpatialIndex si = new RTree();
    si.init(null);

    // We have some points or rectangles in some other data structure.
    // The rtree can handle millions of these.
    Rectangle[] rects = new Rectangle[] {
        new Rectangle(0, 0, 0, 0),
        new Rectangle(0, 1, 0, 1),
        new Rectangle(1, 0, 1, 0),
        new Rectangle(1, 1, 1, 1),
    };

    // Add our data to the rtree. Every time we add a rectangle we give it
    // an ID. This ID is what is returned by querying the rtree. In this 
    // example we use the array index as the ID.
    for (int i = 0; i < rects.length; i++) {
      si.add(rects[i], i);
    }

    // Now see which of these points is contained by some
    // other rectangle. The rtree returns the results of a query
    // by calling the execute() method on a TIntProcedure.
    // In this example we want to save the results of the query 
    // into a list, so that's what the execute() method does.
    class SaveToListProcedure implements TIntProcedure {
      private List<Integer> ids = new ArrayList<Integer>();

      @Override
      public boolean execute(int id) {
        ids.add(id);
        return true;
      }; 

      private List<Integer> getIds() {
        return ids;
      }
    };

    SaveToListProcedure myProc = new SaveToListProcedure();
    si.contains(new Rectangle(-0.5f, -0.5f, 1.5f, 0.5f), myProc);

    List<Integer> ids = myProc.getIds();

    for (Integer id : ids) {
      log.info(rects[id].toString() + " was contained");
    }

    // Actually that was a really long winded (and inefficient) way of 
    // printing out the rectangles. Would be better to use an anonymous
    // class to just do the printing inside the execute method. That is
    // what the NearestN class does.
  }
}

第18行定义了
main

JSI使用的是Trove 2.0.2。直到3.x他们才把程序放进那个包里。降级包显然对我有用。

如果您不是使用maven构建,那么当前您需要trove4j版本2.0.2。JSI的下一个版本(1.1版)将依赖于Trove3.0.3(主分支不久前更新)

另外请注意,关于运行jsi示例的详细说明,请参见我对该问题的回答:


亚历德。

很抱歉,我没有听到你的答案。谢谢你的帮助!
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

    at net.sourceforge.jsi.examples.Contains.main(Contains.java:18)