我如何使用jGrasp的库?

时间:2018-02-08 19:19:58

标签: import jgrasp

我有一个文件夹,里面装满了我上课的课程。随着jGrasp的全新安装,以前运行良好的旧项目现在充满了“未找到符号”错误。

我仍然有图书馆,但我不知道如何导入它们。我们的类的设置方式,你不需要为库中的任何东西导入语句。

/* Turtle Drawing Program Lab 6, Part B */
/* Started by Celine Latulipe , modified by Bruce Long*/

public class Lab6PartB {
  public static void main(String [] args) 
  {
    /* Create the world */
    World w = new World();

    /* Create the turtle, call him Tom */
    Turtle tom = new Turtle(w);

    /* test the getDistance2() method */
    int dist = tom.getDistance2();
    System.out.println("This should print out the value 400. Value is: " + dist);

    tom.moveTo(500, 400);
    dist = tom.getDistance2();
    System.out.println("This should print out the value 640. Value is: " + dist);

    // TODO: Add a third test case that you make up

  }
}

错误:

 ----jGRASP exec: java Lab6PartB
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: ModelDisplay
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: ModelDisplay
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.

1 个答案:

答案 0 :(得分:0)

您可以在操作系统级别或使用“设置”>将包含类文件的目录添加到类路径中。 “PATH / CLASSPATH”> jGRASP中的“工作区”。

此外,您可以将所有类文件/目录复制到包含新项目类的文件夹中。