这个文件名也要是HelloWorld.java

解决方案 »

  1.   

    没有问题啊,我编译通过!
    D:\>javac HelloWorld.javaD:\>java HelloWorld
    HelloWorld!D:\>
      

  2.   

    你的错误原因是说class没找到,你看看有没有拼写错误。或者编译的时候
    D:\>javac HelloWorld.Java
    javac: invalid flag: HelloWorld.Java
    Usage: javac <options> <source files>
    where possible options include:
      -g                        Generate all debugging info
      -g:none                   Generate no debugging info
      -g:{lines,vars,source}    Generate only some debugging info
      -nowarn                   Generate no warnings
      -verbose                  Output messages about what the compiler is doing
      -deprecation              Output source locations where deprecated APIs are us
    ed
      -classpath <path>         Specify where to find user class files
      -sourcepath <path>        Specify where to find input source files
      -bootclasspath <path>     Override location of bootstrap class files
      -extdirs <dirs>           Override location of installed extensions
      -d <directory>            Specify where to place generated class files
      -encoding <encoding>      Specify character encoding used by source files
      -source <release>         Provide source compatibility with specified release
      -target <release>         Generate class files for specific VM version
      -help                     Print a synopsis of standard options
    后缀用了.Java
      

  3.   

    文件名没错,HelloWorld,java
    编译通过,但是java HelloWorld时就出错了
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
      

  4.   

    在CLASSPATH中加上".;"(点加一个分号)
      

  5.   

    我的classpath是这样的C:\j2sdk1.4.0\lib\tools.jar;
    C:\j2sdk1.4.0是我的J2sdk安装目录
    怎么改?
      

  6.   

    java -classpath ""; HelloWorld
      

  7.   

    jdk开发中系统环境变量设置:
    方法如下:
    Win2000中:
    右键我的电脑--》属性--》高级--》环境环境变量
    classpath=.;jdk安装目录\lib
    path=jdk安装目录\bin
    注意:一定不可忽略“.”。
    Win98中:
    修改autocexe.bat 就是修改自动批处理文件。
    添加:
    set classpath=.;jdk安装目录\lib
    set path=jdk安装目录\bin;%path%
      

  8.   

    这个问题很奇怪,有一次我在redhat8.0下测试这个例子的时候,java HelloWorld.class不行,而用java HelloWorld就可以了
      

  9.   

    本来就不能用java HelloWorld.class的,运行class文件只能用java HelloWorld