package test;
import java.math.BigInteger;
import nuim.cs.crypto.blitz.constants.Constant;
import nuim.cs.crypto.primality.Gordon;public class test2 {    public static void main(String[] args) {
Gordon g=new Gordon();
    }
}这么做会出错,Gordon类在下面,constant是一个库中的类,
Exception in thread "main" java.lang.NoClassDefFoundError: nuim/cs/crypto/blitz/constants/Constant
at nuim.cs.crypto.primality.Gordon.<init>(Gordon.java:72)
at nuim.cs.crypto.primality.Gordon.<init>(Gordon.java:28)
at test.test2.main(test2.java:22)
Caused by: java.lang.ClassNotFoundException: nuim.cs.crypto.blitz.constants.Constant
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)package nuim.cs.crypto.primality;import java.math.BigInteger;
import java.util.Random;
import nuim.cs.crypto.blitz.constants.Constant;
public class Gordon {
    public static final BigInteger RANDOM_INT = new BigInteger( "27192" );
    
    protected BigInteger p;
    protected BigInteger r;
    protected BigInteger s;
    protected BigInteger t;
    
    public Gordon() {
        this( 10, 16, new Random(), Gordon.RANDOM_INT, Gordon.RANDOM_INT );
    }
    
    public Gordon( int bitLength ) {
        this( bitLength, 16, new Random(), Gordon.RANDOM_INT, Gordon.RANDOM_INT );
    }
    
    public Gordon( int bitLength, int certainty, Random rnd, BigInteger i, 
        BigInteger j ) {
        if( bitLength <= 0 ) {
            throw new IllegalArgumentException( 
                "bitLength must be greater than zero" );
        }
        if( certainty <= 0 ) {
            throw new IllegalArgumentException( 
                "certainty must be greater than zero" );
        }
        if( rnd == null ) {
            throw new NullPointerException( "rnd cannot be null" );
        }
        if( i == null ) {
            throw new NullPointerException( "i cannot be null" );
        }
        if( i.compareTo( BigInteger.ZERO ) <= 0 ) {
            throw new IllegalArgumentException( "i must be greater than zero" );
        }
        if( j == null ) {
            throw new NullPointerException( "j cannot be null" );
        }
        if( j.compareTo( BigInteger.ZERO ) <= 0 ) {
            throw new IllegalArgumentException( "j must be greater than zero" );
        }
            
        BigInteger s = new BigInteger( bitLength, certainty, rnd );
        BigInteger t = new BigInteger( bitLength, certainty, rnd );        BigInteger r = Constant.TWO.multiply(i).multiply(t);
        r = r.add( BigInteger.ONE );
        
        while( !( r.isProbablePrime( 10 ) ) ) {
            r = r.add( Constant.TWO.multiply( t ) );
        }
        BigInteger p0 = s.modPow( r.subtract( Constant.TWO ), r );
        p0 = p0.multiply( s.multiply( Constant.TWO ) );
        p0 = p0.subtract( BigInteger.ONE );
        BigInteger p = Constant.TWO.multiply( j ).multiply( r ).multiply( s );
        p = p.add( p0 );        while( !( p.isProbablePrime( 10 ) ) ) {
            p = p.add( Constant.TWO.multiply( r ).multiply( s ) );
        }
        
        set( p, r, s, t );
    }
    
    protected void set( BigInteger p, BigInteger r, BigInteger s, 
        BigInteger t ) {
        if( p == null ) {
            throw new NullPointerException( "p cannot be null" );
        }
        if( !p.isProbablePrime( 10 ) ) {
            throw new IllegalArgumentException( "p must be a prime" );
        }
        if( r == null ) {
            throw new NullPointerException( "r cannot be null" );
        }
        if( !r.isProbablePrime( 10 ) ) {
            throw new IllegalArgumentException( "r must be a prime" );
        }
        if( s == null ) {
            throw new NullPointerException( "s cannot be null" );
        }
        if( !s.isProbablePrime( 10 ) ) {
            throw new IllegalArgumentException( "s must be a prime" );
        }
        if( t == null ) {
            throw new NullPointerException( "t cannot be null" );
        }
        if( !t.isProbablePrime( 10 ) ) {
            throw new IllegalArgumentException( "t must be a prime" );
        }
        BigInteger rMinus1 = r.subtract( BigInteger.ONE );
        if( rMinus1.remainder( t ).compareTo( BigInteger.ZERO ) != 0 ) {
            throw new IllegalArgumentException( "t must be a factor of r - 1" );
        }
        this.t = new BigInteger( t.toString() );
        
        BigInteger pPlus1 = p.add( BigInteger.ONE );
        if( pPlus1.remainder( s ).compareTo( BigInteger.ZERO ) != 0 ) {
            throw new IllegalArgumentException( "s must be a factor of p + 1" );
        }
        this.s = new BigInteger( s.toString() );
        
        BigInteger pMinus1 = p.subtract( BigInteger.ONE );
        if( pMinus1.remainder( r ).compareTo( BigInteger.ZERO ) != 0 ) {
            throw new IllegalArgumentException( "r must be a factor of p - 1" );
        }        
        this.r = new BigInteger( r.toString() );        
        this.p = new BigInteger( p.toString() );
    }
    
    public BigInteger getP() {
        return( new BigInteger( p.toString() ) );
    }
    
    public BigInteger getR() {
        return( new BigInteger( r.toString() ) );
    }
    
    public BigInteger getS() {
        return( new BigInteger( s.toString() ) );        
    }
    
    public BigInteger getT() {
        return( new BigInteger( t.toString() ) );
    }
    
    public boolean equals( Object obj ) {
        if( obj instanceof Gordon ) {
            Gordon g = (Gordon) obj;
            return( p.compareTo( g.p ) == 0 && r.compareTo( g.r ) == 0 &&
                    s.compareTo( g.s ) == 0 && t.compareTo( g.t ) == 0 );
        }
        else {
            return( false );
        }
    }
}这样做没错,…… 很无语,是不是权限问题????public class ibetest
{
    public static void main(String[] args) {
new Gordon();
    }
 }
 class Gordon {
//和上面的那个类一样就是放到新建的一个java文件里面
}

解决方案 »

  1.   

    应该是你的包的排列问题,你的包目录是什么样的。发上来看一下,还有你用的是什么IDE?还是用dos
      

  2.   

    Gordon 这个类没有在CLASSPATH 里面,楼上说的很对,/test/test2.class
    /nuim/cs/crypto/primality/Gordon.class在 /目录下面运行java -cp . test.test2
      

  3.   

    它的错不是那个了,,,你昨天换ide版本就好了吧,呵呵,小俊杰同学
      

  4.   

    你的包目录没写对吧,如果你用IDE的话,那就重新配一次,如果用JAVA命令,那就指定CLASSPATH呗,-CP参数,就好了