线程“ main”中的异常java.lang.NoClassDefFoundError:您好 [英] Exception in thread "main" java.lang.NoClassDefFoundError: Hello
问题描述
这是我的第一个Java项目。我正在使用Ubuntu。
This is my first project with Java. I'm using Ubuntu.
我在文件夹 / home / anis / jtest / myProject
中,并且运行Hello.java文件与:
I'm in the folder /home/anis/jtest/myProject
and I run the Hello.java file with :
javac src/org/example/Hello.java
似乎可行。我没有错误,也没有在示例目录中找到一个Hello.class文件。
Seems that works. I get no error and a Hello.class file in the example directory.
然后再次从 myProject
区域中获取运行:
Then from the myProject
firectory again I run :
java -cp src/org/example Hello
,我得到了错误:线程 main java.lang.NoClassDefFoundError中的异常:Hello(错误名称:org / example / Hello)
and I get the error : Exception in thread "main" java.lang.NoClassDefFoundError: Hello (wrong name: org/example/Hello)
我的Hello.java代码为:
My code for Hello.java is :
package org.example;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello\n");
}
}
推荐答案
在文件夹src /:
$ javac org/example/Hello.java
$ java org.example.Hello
这篇关于线程“ main”中的异常java.lang.NoClassDefFoundError:您好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!