Install Java through apt-Get install

Source: Internet
Author: User

Under UbuntuApt-Get installIt's really easy to use,

If you are not sure about the package name to be installed,

You can also enter two letters startingTab keyTo give a prompt.

The following is how to install JavaJDKExample:

I want to compile and execute Java programs in Linux,

Java program needsJDKAndJVM,

The JDK package name is unknown,

Enter:

Sudo apt-Get install sun-

Then pressTab keyUbuntu will provide a list of names of all software packages starting with Java Characters Based on the software installation source,

As a result, we can see:Sun-java6-jdk,

Then complete the input: sudo apt-Get install sun-java6-jdk, (and for success, but sudo apt-Get install openjdk-6-jdk), or when you are running a Java program, you will be prompted to install something...

Complete software installation as prompted.

Write a simple programTestNext let's take a look:

Enter a directory,

Then create. JavaFile: VI test. Java

Enter the following code:

Public class test {

Public static void main (string [] ARGs ){

System. Out. println ("Hello World ");

}

}

Save and exit VI: , Press Enter.

Compile test. Java:JavacTest. Java

Run test:JavaTest

The output string is Hello world.

Indicates that JDK and JVM have been installed in the Java development environment.

You may also need to setClasspath environment variable,

Available in Ubuntu/Etc/environmentFile,

Add code:Export classpath= "Path" (note that multiple paths are usedColon: Not separated by semicolons (; different from Windows)

By the wayJava_homeAlso set: Export java_home = "/usr/lib/JVM/Java-6-sun-1.6.0.15"

Then modify the default usageOpenjdkIsSun-JDK:

Sudo Update-Alternatives-- Config Java

Select sun-JDK as prompted;

Restart your computer.

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.