执行一个java程序的时候报这个错 请问是怎么回事
Exception in thread "main" java.lang.NoClassDefFoundError: peersim/Simulator

解决方案 »

  1.   

    没有找到类peersim/Simulator 
    你是怎么执行的,用命令的话要设置好环境变量
      

  2.   

    出现此问题是因为classpath设置错误。设置环境变量如下:java_home=C:\Program Files\Java\jdk 1.5.0_05classpath=.;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;(注意最前边是一点再一分号,这是表示当前路径,即环境变量classpath必须包含当前路径才行,如果不包括,需要用set classpath = %classpath%;e:\myjava临时设置)就再设置下classpath的路径,根据文件所在地方。set classpath=%classpath%;F:\classes;这样设一下就可以解决问题了。
      

  3.   

    是我下的一个包 用这个命令执行
    java -cp "peersim-1.0.3.jar:jep-2.3.0.jar:djep-1.0.0.jar" peersim.Simulator example/config-example1.txt
      

  4.   

    Waiting for reading your code...
      

  5.   

    public class Simulator {// ========================== static constants ==========================
    // ======================================================================/** {@link CDSimulator} */
    public static final int CDSIM = 0;/** {@link EDSimulator} */
    public static final int EDSIM = 1;/** Unknown simulator */
    public static final int UNKNOWN = -1;/** the class names of simulators used */
    protected static final String[] simName = {
    "peersim.cdsim.CDSimulator",
    "peersim.edsim.EDSimulator",
    };/**
     * Parameter representing the number of times the experiment is run.
     * Defaults to 1.
     * @config
     */
    public static final String PAR_EXPS = "simulation.experiments";

    /**
     * If present, this parameter activates the redirection of the standard
     * output to a given PrintStream.
     * This comes useful for processing the output of the simulation from
     * within the simulator.
     * @config
     */
    public static final String PAR_REDIRECT = "simulation.stdout";// ==================== static fields ===================================
    // ======================================================================/** */
    private static int simID = UNKNOWN;//========================== methods ===================================
    //======================================================================/**
    * Returns the numeric id of the simulator to invoke. At the moment this can
    * be {@link #CDSIM}, {@link #EDSIM} or {@link #UNKNOWN}.
    */
    public static int getSimID() {

    if (simID == UNKNOWN) {
    if( CDSimulator.isConfigurationCycleDriven()){
    simID = CDSIM;
    }
    else if( EDSimulator.isConfigurationEventDriven() ) {
    simID = EDSIM;
    }
    }
    return simID;
    }// ----------------------------------------------------------------------/**
    * Loads the configuration and executes the experiments.
    * The number of independent experiments is given by config parameter
    * {@value #PAR_EXPS}. In all experiments the configuration is the same,
    * only the random seed is not re-initialized between experiments.
    * <p>
    * Loading the configuration is currently done with the help of constructing
    * an instance of {@link ParsedProperties} using the constructor
    * {@link ParsedProperties#ParsedProperties(String[])}.
    * The parameter
    * <code>args</code> is simply passed to this class. This class is then used
    * to initialize the configuration.
    * <p>
    * After loading the configuration, the experiments are run by invoking the
    * appropriate engine, which is identified as follows:
    * <ul>
    * <li>{@link CDSimulator}:
    * if {@link CDSimulator#isConfigurationCycleDriven} returns
    * true</li>
    * <li>{@link EDSimulator}:
    * if {@link EDSimulator#isConfigurationEventDriven} returns
    * true
    * </li>
    * </ul>
    * <p>
    * This list represents the order in which these alternatives are checked.
    * That is, if more than one return true, then the first will be taken.
    * Note that this class checks only for these clues and does not check if the
    * configuration is consistent or valid.
    * @param args passed on to
    * {@link ParsedProperties#ParsedProperties(String[])}
    * @see ParsedProperties
    * @see Configuration
    * @see CDSimulator
    * @see EDSimulator
    */
    public static void main(String[] args)
    {
    long time = System.currentTimeMillis();

    System.err.println("Simulator: loading configuration");
    Configuration.setConfig( new ParsedProperties(args) ); PrintStream newout =
    (PrintStream)Configuration.getInstance(PAR_REDIRECT,System.out);
    if(newout!=System.out) System.setOut(newout);

    int exps = Configuration.getInt(PAR_EXPS,1); final int SIMID = getSimID();
    if( SIMID == UNKNOWN )
    {
    System.err.println(
        "Simulator: unable to identify configuration, exiting.");
    return;
    }

    try { for(int k=0; k<exps; ++k)
    {
    if( k>0 )
    {
    long seed = CommonState.r.nextLong();
    CommonState.initializeRandom(seed);
    }
    System.err.print("Simulator: starting experiment "+k);
    System.err.println(" invoking "+simName[SIMID]);
    System.err.println("Random seed: "+
    CommonState.r.getLastSeed());
    System.out.println("\n\n");

    // XXX could be done through reflection, but
    // this is easier to read.
    switch(SIMID)
    {
    case CDSIM:
    CDSimulator.nextExperiment();
    break;
    case EDSIM:
    EDSimulator.nextExperiment();
    break;
    }
    }

    } catch (MissingParameterException e) {
    System.err.println(e+"");
    System.exit(1);
    } catch (IllegalParameterException e) {
    System.err.println(e+"");
    System.exit(1);
    } // undocumented testing capabilities
    if(Configuration.contains("__t")) 
    System.out.println(System.currentTimeMillis()-time);
    if(Configuration.contains("__x")) Network.test();



    }}
    这是主程序的入口
      

  6.   

    环境变量没设置好 .java的文件在哪个盘下,把那个盘地址放在classpath下
      

  7.   

    java -cp "peersim-1.0.3.jar:jep-2.3.0.jar:djep-1.0.0.jar" peersim.Simulator example/config-example1.txt在Windows下将“:”改为“;”
      

  8.   

    环境变量没有配好
    javahome=.;C:\Program Files\Java\jdk 1.5.0_05 
    classpath=.;C:\Program Files\Java\jdk 1.5.0_05 \bin