'Compile java file in linux [closed]

I have added environment variables in /etc/profile and the compiled file has no package name. Why java Hello can not work and appear java.lang.ClassNotFoundException: HelloWorld. I would like to know where is the problem, thanks.

compile java file in linux Here is the code.

public class HelloWorld {
    public static void main(String args[]) {
        System.out.println("Hello world on Linux.");
    }
}

Linux execute java command Error: Main class not found or loaded
java环境变量配置可参考
Java环境变量配置(CentOS)

以上回答转自博客园提问 谢谢 ycyzharry



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source