Setting the environment variables for Java in Unbuntu

Source: Internet
Author: User

In the process of compiling spice found a lot of things are under Linux, so under the Unbuntu to configure an Android environment, first of all, the first configuration of the Java environment.

Tools/Ingredients:

    • JDK-8U25-LINUX-X64.TAR.GZ (latest 1.8 version)

    • ubuntu12.04 above version (14.04 X64 is used here)

Method/Step:

  1. First we need to download the JDK, open Orcle's official website to download jdkhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html , I am under the latest version of jdk-8u25-linux-x64.tar.gz
  2. Then in the personal home folder to create a new folder, I named Java, my user name whj, so the full directory is/home/whj/java (official web also has a RPM format, where I download the GZ format, RPM is a package directly packaged), and then the jdk-8u25-linux-x64.tar.gz copied to the/home/whj/java/directory, for the newly-started friends, the command may not be able to understand the meaning of the instructions, in this graphic way to do. The right mouse button-> Use the Archive Manager to open, then you can see everything inside, we need to extract it out,:
  3. Directly Click Extract to extract all the files, it will be extracted to the current directory, at this time the JDK directory is /home/whj/java/jdk1.8.0_25.
  4. The following directly to configure the environment variables, here are two configuration methods, one is to enter sudo gedit/etc/environment carriage return in the terminal, will ask for a password, and then open a file, here I do not know where there is a problem, the first time to open the text, The second time you open a blank, after entering the prompt file does not exist.
  5. The first way to fail is to try the second method:

    $sudo gedit ~/.BASHRC

    Add the following code:

    Export java_home=/home/whj/java/jdk1.8.0_25

    Export JRE_HOME=${JAVA_HOME}/JRE

    Export Classpath=.:${java_home}/lib:${jre_home}/lib

    Export Path=${java_home}/bin: $PATH

  6. To see if the configuration was successful: Java-version

    Have the following information configured successfully! (This may need to be restarted once and can be restarted again before looking at the results)

  7. After the installation is successful, we can test it with an example: Create a new file in the/home/whj/directory Hello.java, open, enter the following
    public class hello{public    static void Main (String args[]) {        System.out.println ("Hello Wrold");    
  8. After saving in the terminal input Javac Hello.java (note, is the/home/whj/directory under the new Hello.java file, otherwise, run this command need to go to the corresponding directory, you can first try the LS command in the terminal, you can list the current directory of all files)
  9. If the output is Hello World, it means the configuration is ready,
  10. Here the configuration is completely successful. The JDK environment has been built.

Setting the environment variables for Java in Unbuntu

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.