Java program compiled under Ubuntu

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.