ClassNotFound on running (no compilation errors in 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 :/
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:
java -cp ./path_to_jar Example
精彩评论