很简单的一段java程序,各位帮忙看看错在哪里?代码和错误如下:(50分)

  • 主题发起人 润五月
  • 开始时间

润五月

Unregistered / Unconfirmed
GUEST, unregistred user!
[red]这段程序编译可以通过,执行的时候报错![/red]
源程序如下:
import java.io.*;
public class TestHiddenField
{
public static void main(String args[])
{
D200_Card my200=new D200_Card();
my200.balance=50.0;
System.out.println("父类被隐藏的金额为"+my200.getbalance());
if(my200.performDial())
System.out.println("子类的剩余金额为:"+my200.balance);
}
}
abstract class PhoneCard
{
do
uble balance;
abstract boolean performDial();
do
uble getbalance()
{
return balance;
}
}
abstract class Number_PhoneCard extends PhoneCard
{
long cardNumber;
int password;
String connectNumber;
boolean connected;
boolean performConnection(long cn,int pw)
{
if(cn==cardNumber&&pw==password)
{
connected=true;
return true;
}
else
return false;
}
}
class D200_Card extends Number_PhoneCard
{
do
uble additoryFee;
do
uble balance;
boolean performDial()
{
if(balance>(0.5+additoryFee))
{
balance-=(0.5+additoryFee);
return true;
}
else
return false;
}
do
uble getBalance()
{
return balance;
}
}
错误信息:
Exception in thread "main" java.lang.NoClassDefFoundError:
C:/Documents and Settings/Administrator/Desktop/TestHiddenField/class
 
C:/PWIN95/Desktop>g:/jdk1.4/bin/javac TestHiddenField.java
C:/PWIN95/Desktop>g:/jdk1.4/bin/java TestHiddenField
父类被隐藏的金额为0.0
子类的剩余金额为:49.5
我可以执行的,你的CLASSPATH有问题必须有"."就是当前目录才行。
 
楼上的:
这样不可以吗?
java "C:/Documents and Settings/Administrator/Desktop/TestHiddenField.class"
 
java "C:/Documents and Settings/Administrator/Desktop/TestHiddenField.class"
当然不行了,看看下面,java后面的参数是class,又不是class file name。
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)
where options include:
-hotspot to select the "hotspot" VM
-server to select the "server" VM
-classic to select the "classic" VM
If present, the option to select the VM must be first.
The default VM is -hotspot.
-cp -classpath <directories and zip/jar files separated by ;>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options
 
多人接受答案了。
 
顶部