运行时ClassNotFound(eclipse中没有编译错误)
正如我在标题中所描述的,我在 eclipse 中有一个非常简单的 Java 项目。在项目中我有 2 个包:
com.tester.beta.api 和 com.tester.beta.sample
api 包有一些类,示例项目只有一个具有 main 功能的类:
package com.tester.beta.sample;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.tester.beta.api.Analyzer;
public class Example
{
/**
* @param args
*/
public static void main(String[] args)
{
//I load some files from the hdd
Analyzer analyzer = new Analyzer();
}
}
我在 eclipse 中没有编译错误 - 一切似乎都工作正常。但是当我运行该项目并且当它进入此行时Analyzeranalysiser=newAnalyzer(); 我收到 ClassNotFound 异常...
我尝试过清理、重建、刷新项目。重新启动eclipse,电脑,一切。我尝试手动将输出文件夹添加到项目构建路径中 - 没有任何帮助。有人知道这里出了什么问题吗?这一定是一件微不足道的事情,但我在谷歌上花了很多时间,但没有结果:/
As I Have described in the title I have a very simple Java Project in eclipse. In the project I have 2 packages:
com.tester.beta.api and
com.tester.beta.sample
The api package has some classes, and the sample project has only one class with main function:
package com.tester.beta.sample;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.tester.beta.api.Analyzer;
public class Example
{
/**
* @param args
*/
public static void main(String[] args)
{
//I load some files from the hdd
Analyzer analyzer = new Analyzer();
}
}
I have no compilation errors in eclipse - everything seems to be working fine. But when I run the project and when it goes to this line Analyzer analyzer = new Analyzer();
I get a ClassNotFound Exception...
I have tried cleaning, rebuilding, refreshing the project. restarting eclipse, pc, everything. I tried adding the output folders to the project build path manually - nothing helps. Does any one have an idea what is wrong here? It must be something trivial but I have spent many times on google with no results :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您得到一个未找到的类,因为包含
Analyzer
类的 jar 文件(或文件夹)不在您的类路径中。你的班级管理得怎么样?
如果在命令行模式下运行,则必须指定类路径,如下所示:
You get a class not found because the jar file (or folder) containing the
Analyzer
class is not in your classpath.How are you running the class?
If you are running in command line mode, you have to specify the classpath as follows: