开发者

I compile 'myclass.java' with javac and no errors, however when I run 'myclass.class' with java it says NoClassDefFoundError?

开发者 https://www.devze.com 2023-02-23 04:56 出处:网络
How is it not found if it was able to find it to run itself?? Here is the code: class myclass{ int x = 10;

How is it not found if it was able to find it to run itself?? Here is the code:

class myclass{

   int x = 10;

   int Voo(int x){
      x += 4;
      return x;

   }

   int VooUp(int x){
      x+= 7;
      return 7; 
   }


   public static void main(String[] args){

      myclass obj = new myclass();

      System.out.println( obj.Voo(obj.x) ); 
      System.out.println( obj.x );


   }

}

java myclass.class fails saying myclass 开发者_运维技巧definition is not found... :(


Don't use the ".class" extension when specifying the class to run.

You may need a classpath argument as well; e.g.

java -cp . myclass


The command line you need is:

java -cp . myclass
0

精彩评论

暂无评论...
验证码 换一张
取 消