| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:[讨论]在ide中可运行但在cmd.exe中就不行,大家看看
只看楼主 加入收藏
the_king
Rank: 1
等 级:新手上路
威 望:1
帖 子:70
专家分:0
注 册:2007-9-14
收藏
 问题点数:0 回复次数:4 
[讨论]在ide中可运行但在cmd.exe中就不行,大家看看

以下这处程序在ide中能运行,但在cmd.exe中就不能,大家讨论讨论
import java.util.*;

public class Guess
{
public static void main(String args[])
{
int a=0,m=0,n=100;
int b=(int)(Math.random()*100)+1;

Scanner reader=new Scanner(System.in);

while(a!=b)
{ System.out.println("请输入你的值");
a=reader.nextInt();
if(a<0||a>100)
{
System.out.println("哈哈,你已走入误区请回头试试");
}

else if(a>b)
{
System.out.println("你离答案已经很近,请继续\n");
System.out.println("系统所给的数应在m与a之间\n"+m+a);
n=a;
}

else if(a<b)
{
System.out.println("你离答案已经很近了,请继续");
System.out.println("系统所给的数应在b与n之间"+b+n);
m=a;
}
else if(a==b)
{
System.out.println("恭喜你猜对了!!!!!");
System.out.println("系统所给的值是:"+b);
}
}
}
}
在cmd.exe中提示这样的错误...
C:\>java Guess
Exception in thread "main" java.lang.NoClassDefFoundError: Guess


搜索更多相关主题的帖子: ide cmd exe 运行 
2007-09-15 19:55
george_vcool
Rank: 2
等 级:新手上路
威 望:3
帖 子:453
专家分:0
注 册:2007-7-23
收藏
得分:0 
classpath的问题
2007-09-15 19:57
HK狼
Rank: 1
等 级:新手上路
威 望:1
帖 子:46
专家分:0
注 册:2007-9-9
收藏
得分:0 

看文件名和类名是否一样
之后
javac Guess.java
java Guess


2007-09-16 10:17
the_king
Rank: 1
等 级:新手上路
威 望:1
帖 子:70
专家分:0
注 册:2007-9-14
收藏
得分:0 

谢谢楼上的

不过文件名与类名是一样,而且passth也是对的

2007-09-16 16:34
the_king
Rank: 1
等 级:新手上路
威 望:1
帖 子:70
专家分:0
注 册:2007-9-14
收藏
得分:0 

我把那个程序完善了一下,代码如下:
import java.util.*;

public class Guess
{
public static void main(String args[])
{
int a=0,m=0,n=100;
int b=(int)(Math.random()*100)+1;

Scanner reader=new Scanner(System.in);

while(a!=b)
{ System.out.println("请输入你的值");
a=reader.nextInt();
if(a<0||a>100)
{
System.out.println("哈哈,你已走入误区请回头试试");
}

else if(a>b)
{
System.out.println("你离答案已经很近,请继续\n");
n=a;
System.out.printf("系统所给的数应在%d与%d之间\n",m,n);
}

else if(a<b)
{
System.out.printf("你离答案已经很近了,请继续");
m=a;
System.out.printf("系统所给的数应在%d与%d之间\n",m,n);

}
else if(a==b)
{
System.out.println("恭喜你猜对了!!!!!");
System.out.println("系统所给的值是:"+b);
}
}
}
}

2007-09-16 16:35
快速回复:[讨论]在ide中可运行但在cmd.exe中就不行,大家看看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028467 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved