关于java最基本的环境配置问题

donwmufromdying 2006-04-14 07:26:25
我设置了classpath,编译也正常,java Music5就报异常
java.lang.NoClassDefFoundError 不清楚!
源码转自thinking in java
//: c08:music5:Music5.java// Interfaces.
import java.util.*;

interface Instrument {
// Compile-time constant:
int i = 5; // static & final// Cannot have method definitions:
void play(); // Automatically public
String what();
void adjust();
}

class Wind implements Instrument {
public void play() {
System.out.println("Wind.play()");
}
public String what() { return "Wind"; }
public void adjust() {}
}

class Percussion implements Instrument {
public void play() {
System.out.println("Percussion.play()");
}
public String what() { return "Percussion"; }
public void adjust() {}
}

class Stringed implements Instrument {
public void play() {
System.out.println("Stringed.play()");
}
public String what() { return "Stringed"; }
public void adjust() {}
}

class Brass extends Wind {
public void play() {
System.out.println("Brass.play()");
}
public void adjust() {
System.out.println("Brass.adjust()");
}
}

class Woodwind extends Wind {
public void play() {
System.out.println("Woodwind.play()");
}
public String what() { return "Woodwind"; }
}

public class Music5 {
// Doesn't care about type, so new types// added to the system still work right:
static void tune(Instrument i) {
// ...
i.play();
}
static void tuneAll(Instrument[] e) {
for(int i = 0; i < e.length; i++)
tune(e[i]);
}
public static void main(String[] args) {
Instrument[] orchestra = new Instrument[5];
int i = 0;
// Upcasting during addition to the array:
orchestra[i++] = new Wind();
orchestra[i++] = new Percussion();
orchestra[i++] = new Stringed();
orchestra[i++] = new Brass();
orchestra[i++] = new Woodwind();
tuneAll(orchestra);
}
} ///:~
...全文
180 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
donwmufromdying 2006-04-14
  • 打赏
  • 举报
回复
ok!!多谢!结贴给分!
btb368 2006-04-14
  • 打赏
  • 举报
回复
你把下面路径复制过去就可以了
classpath=.;%JAVA_HOME%\jre\lib;
令外你的classpath前面还需要一个.这个可不能缺少
donwmufromdying 2006-04-14
  • 打赏
  • 举报
回复
多谢!我贴处理,恐怕有什么jar没包含
classpath=%JAVA_HOME%\lib\tools.jar
zy_weiliang 2006-04-14
  • 打赏
  • 举报
回复
一般来说是classpath出错了 你把你的classpath给我看看
还有你的类所在的路径

62,614

社区成员

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

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