新手求教啊!~~~~(在线等待!~~~~)

lamyoyo 2002-04-10 08:19:41
我按照《Java2核心技术 卷I》那本书里面的介绍
下了个2125corejava
然后解压
将文件夹更名为CoreJavaBook后
拷贝到c盘跟目录下
然后更改autoexe.bat
添加
SET CLASSPATH=.;C:\CoreJavaBook\corejava

重启后
运行书上的例程
import corejava.*;

public class ConsoleTest
{
public static void main(String[] args)
{
double x = Console.readDouble
("Enter a number,I'll add 2 to it.");
System.out.println(x + 2);
}
}

结果编译不过去
报错
E:\java\ConsoleTest.java:1: package corejava does not exist
import corejava.*;
^
E:\java\ConsoleTest.java:7: cannot access Console
bad class file: .\Console.class
class file contains wrong class: corejava.Console
Please remove or make sure it appears in the correct subdirectory of the classpath.
double x = Console.readDouble
^
2 errors

工具以退出代码 1 完成
然后我将文件考到C:\CoreJavaBook下
报错
C:\CoreJavaBook\ConsoleTest.java:7: cannot access Console
bad class file: C:\CoreJavaBook\corejava\Console.class
class file contains wrong class: corejava.Console
Please remove or make sure it appears in the correct subdirectory of the classpath.
double x = Console.readDouble
^
1 error

我搞不明白
哪位先人能指点指点么?
...全文
48 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lamyoyo 2002-04-11
  • 打赏
  • 举报
回复
E:\java\ConsoleTest.java:7: cannot access Console
bad class file: .\Console.class
class file contains wrong class: corejava.Console
Please remove or make sure it appears in the correct subdirectory of the classpath.
double x = Console.readDouble

SET CLASSPATH=C:\j2sdk1.4.0\jre\lib\rt.jar;E:\java;C:\CoreJavaBook;.
还是有这个错误
javalearner 2002-04-11
  • 打赏
  • 举报
回复
同意bill_hongs&jianghuxiaozi&pengji
aiu 2002-04-11
  • 打赏
  • 举报
回复
import corejava.*;
是不是小写的缘故呀,胡乱猜的,呵呵
pengji 2002-04-11
  • 打赏
  • 举报
回复
SET CLASSPATH=C:\CoreJavaBook;这样就对了!
jianghuxiaozi 2002-04-11
  • 打赏
  • 举报
回复
SET CLASSPATH=C:\CoreJavaBook;
zhangCSDN 2002-04-11
  • 打赏
  • 举报
回复
放到WEB目录下。
SniperPu 2002-04-11
  • 打赏
  • 举报
回复
是不是你的.java文件名与主类名不一致?包括大小写都必须一样,才能编译通过。
bill_hongs 2002-04-11
  • 打赏
  • 举报
回复
set CLASSPATH=c:\CoreJavaBook;.

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧