在Windows MyEclipse6.5下开发了一Java项目,现将其放到Suse Linux下
现在我需要运行的是DataCatcher.class文件
在终端下输入了java DataCatcher结果报错
Exception in thread "main" java.lang.NoClassDefFoundError: DataCatcher (wrong name: catcher/DataCatcher)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
于是改用javac DataCatcher出现以下错误
javac: invalid flag: DataCatcher
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 used
  -classpath <path>          Specify where to find user class files
  -cp <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
  -endorseddirs <dirs>       Override location of endorsed standards path
  -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
  -version                   Version information
  -help                      Print a synopsis of standard options
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
请问怎么办呢?

解决方案 »

  1.   

    没有写javac的完整路径
    你可加上$JAVA_HOME再写:
    $JAVA_HOME/bin/javac DataCatcher.java就应该没有问题了。
      

  2.   

    根据报错信息应该是环境变量没有配置好,楼主用env看一下!
      

  3.   

    1.配置下环境
    2.用javac时,要用javac DataCatcher.java
      

  4.   

    再给你补个资料
    http://lavasoft.blog.51cto.com/62575/112312
      

  5.   

    谢谢 不过我的工程里类很多 我编译完DataCatcher以后又报错说里面引用的其它类找不到
      

  6.   

    javac -d /com/aa/bb DataCatcher.java
    看下你的DataCatcher.java是不是在哪个包下。
      

  7.   

    DataCatcher.java在src/catcher下
    请问不能直接使用class文件吗?