Ubuntu under the Java program to compile the first need to install the JDK, and configure the corresponding environment variables under the simple HelloWorld example file named Helloworld.javajava code: Public classHelloWorld { Public Static voidMain (String args[]) {System. out. println ("Hello world!"); }} Compile: Javac Helloworld.java the HelloWorld is generated in the current folder.classfile run: Java HelloWorld Runtime If an error occurs: Cannot find or Load main class (and English error: Could not find or load mainclassHelloWorld the same) possible workaround:1. File name and class name are inconsistent, case-sensitive resolution: Modify the file name or class name to keep the two consistent2The environment variable is not set correctly so that the running program cannot find the specified main class workaround: A) Specify the main classpath by option for example: Java-classpath. HelloWorld (Specify current directory) b) If the file Helloworld.class is in the current working path, you can modify the environment variable to resolve sudo gedit/etc/Environment in CLASSPATH="***"Previous add":."(classpath=".:****"), that is, add the current work path to classpath immediately using environment variables: source/etc/Environment
Java program compiled under Ubuntu