gpt4 book ai didi

java:编译后无法运行程序?帮我

转载 作者:行者123 更新时间:2023-12-02 06:53:00 24 4
gpt4 key购买 nike

我刚刚下载了一个java程序TableDrivenVaccumAgent.java当我在搜索一些机器人类示例时,我在路径 C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext 中包含了必要的 jar。但是编译成功后出现错误。

我应该做些什么来解决以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: TableDrivenVacuumAgent (wrong name: aima/core/environment/vacuum/TableDrivenVacuumAgent)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

现在错误是:
Exception in thread "main" java.lang.NoClassDefFoundError: TableDrivenVaccumAgent (wrong name: aima/core/environment/vacuum/TableDrivenVaccumAgent)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

最佳答案

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. For example if we have a method call from a class or accessing any static member of a Class and that class is not available during run-time then JVM will throw NoClassDefFoundError.



NoClassDefFoundError 的明显原因是特定类在 Classpath 中不可用,因此我们需要将其添加到 Classpath 中,或者如果我们期望它在 Classpath 中不可用,我们需要检查它为什么不可用。可能有多种原因,例如:
  • 类在 Java 类路径中不可用。
  • 您可能正在使用 jar 命令运行程序,而类是
    未在 list 文件的 ClassPath 属性中定义。
  • 任何启动脚本都会覆盖 Classpath 环境变量。
  • 关于java:编译后无法运行程序?帮我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17792214/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com