当前位置: 技术问答>java相关
刚学java,请问。。。
来源: 互联网 发布时间:2015-01-09
本文导语: // Test.java import java.util.*; public class Test{ public static void main(String[] args){ System.out.println(new Date()); Properties p = System.getProperties(); p.list(System.out); System.out.println(...
// Test.java
import java.util.*;
public class Test{
public static void main(String[] args){
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() );
}
}
C:Java Files>javac test.java
C:Java Files>java test.class
Exception in thread "main" java.lang.NoClassDefFoundError: test/class
为什么运行不了?
import java.util.*;
public class Test{
public static void main(String[] args){
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() );
}
}
C:Java Files>javac test.java
C:Java Files>java test.class
Exception in thread "main" java.lang.NoClassDefFoundError: test/class
为什么运行不了?
|
运行时键入C:Java Files>java test(类不需要扩展名)
|
要设置classpath,查询一下吧,这种问题提过多次了