当前位置: 技术问答>java相关
我编译、运行 《Thinking in java》的第一例子,得不到结果,提示如下:
来源: 互联网 发布时间:2015-02-08
本文导语: Exception in thread "main" java.lang.NoClassDefFoundError: Property/class 请问错在那里?源程序如下: //Property.java import java.util.*; public class Property { public static void main(String[] args) { System.out.println("good"); ...
Exception in thread "main" java.lang.NoClassDefFoundError: Property/class
请问错在那里?源程序如下:
//Property.java
import java.util.*;
public class Property {
public static void main(String[] args) {
System.out.println("good");
System.out.println(new Date());
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("ToTal Memory ="
+ rt.totalMemory()
+ " Free Memory = "
+ rt.freeMemory());
}
}
请问错在那里?源程序如下:
//Property.java
import java.util.*;
public class Property {
public static void main(String[] args) {
System.out.println("good");
System.out.println(new Date());
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("ToTal Memory ="
+ rt.totalMemory()
+ " Free Memory = "
+ rt.freeMemory());
}
}
|
set classpath=c:jdklib;
set path=c:jdkbin;
把以上两句加到atuoexec.bat里~
然后javac Property.java
把编译好的CLASS文件放到CLASSPATH里
java Property
就可以啦~
set path=c:jdkbin;
把以上两句加到atuoexec.bat里~
然后javac Property.java
把编译好的CLASS文件放到CLASSPATH里
java Property
就可以啦~
|
在我的机子上运行正常的呀。
C:down>java Property
good
Thu Oct 04 15:51:50 CST 2001
-- listing properties --
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=C:Program FilesJavaSoftJRE1.4bin
java.vm.version=1.4.0-beta-b65
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
sun.os.patch.level=
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:down
java.runtime.version=1.4.0-beta-b65
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
os.arch=x86
java.io.tmpdir=E:DOCUME~1gxjLOCALS~1Templine.separator=
java.vm.specification.vendor=Sun Microsystems Inc.
java.awt.fonts=
os.name=Windows 2000
java.library.path=E:WINNTsystem32;.;E:WINNTSystem32...
java.specification.name=Java Platform API Specification
java.class.version=48.0
java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFac...
os.version=5.0
user.home=E:Documents and Settingsgxj
user.timezone=Asia/Shanghai
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=GBK
java.specification.version=1.4
user.name=gxj
java.class.path=.;E:beawlserver6.0libweblogic.jar...
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:Program FilesJavaSoftJRE1.4
java.specification.vendor=Sun Microsystems Inc.
user.language=zh
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.4.0-beta
java.ext.dirs=C:Program FilesJavaSoftJRE1.4lib...
sun.boot.class.path=C:Program FilesJavaSoftJRE1.4lib...
java.vendor=Sun Microsystems Inc.
file.separator=java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
user.region=CN
sun.cpu.isalist=pentium i486 i386
---Memory Usage:
ToTal Memory =2031616 Free Memory = 1509872
C:down>java Property
good
Thu Oct 04 15:51:50 CST 2001
-- listing properties --
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=C:Program FilesJavaSoftJRE1.4bin
java.vm.version=1.4.0-beta-b65
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
sun.os.patch.level=
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:down
java.runtime.version=1.4.0-beta-b65
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
os.arch=x86
java.io.tmpdir=E:DOCUME~1gxjLOCALS~1Templine.separator=
java.vm.specification.vendor=Sun Microsystems Inc.
java.awt.fonts=
os.name=Windows 2000
java.library.path=E:WINNTsystem32;.;E:WINNTSystem32...
java.specification.name=Java Platform API Specification
java.class.version=48.0
java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFac...
os.version=5.0
user.home=E:Documents and Settingsgxj
user.timezone=Asia/Shanghai
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=GBK
java.specification.version=1.4
user.name=gxj
java.class.path=.;E:beawlserver6.0libweblogic.jar...
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:Program FilesJavaSoftJRE1.4
java.specification.vendor=Sun Microsystems Inc.
user.language=zh
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.4.0-beta
java.ext.dirs=C:Program FilesJavaSoftJRE1.4lib...
sun.boot.class.path=C:Program FilesJavaSoftJRE1.4lib...
java.vendor=Sun Microsystems Inc.
file.separator=java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
user.region=CN
sun.cpu.isalist=pentium i486 i386
---Memory Usage:
ToTal Memory =2031616 Free Memory = 1509872
|
你是不是classpath没有设置
要把当前目录“./”加进去。这个要自己手工加
要把当前目录“./”加进去。这个要自己手工加