Set java environment variables in Unbuntu, unbuntujava

Source: Internet
Author: User

Set java environment variables in Unbuntu, unbuntujava

During SPICE compilation, many things are found in linux. Therefore, to configure an android environment in unbuntu, configure the java environment first.

Tools/raw materials:
  • Jdk-8u25-linux-x64.tar.gz (latest version 1.8)

  • Ubuntu12.04 or later (14.04X64)

Method/step: 1. First, we need to download JDK, open ORCLE's official website to download JDKhttp: // JDK 2, and create a folder under my main folder. I name it java, my username is whj, so the complete directory is/home/whj/snapshot copied to the/home/whj/java/directory. For Beginners, the command may not understand the meaning of each command. It is made in graphical mode. Right-click the file and choose archive manager to open the file. You can view all the content in the file. decompress the file. 3. Click extract to extract all the files, the jdk directory is/home/whj/java/jdk1.8.0 _ 25. 4. Configure the environment variables directly below. There are two configuration methods here. One is to enter sudo gedit/etc/environment in the terminal and enter the password, then a file will be opened. Here I don't know where the problem is. There is still text when I open it for the first time, and a blank space when I open it for the second time. After I enter the file, the system prompts that the file does not exist. (You can open it again today)
Enter three lines in the file:
Export JAVA_HOME =/home/whj/java/jdk1.8.0 _ 25
Export JRE_HOME =/home/whj/java/jdk1.8.0 _ 25/jre
Export CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib

Note that the last row is followed by .:,
Similarly, in the second file, enter sudo gedit/etc/profile in the terminal and press Enter.
Enter the following four lines in the file:
Export JAVA_HOME =/home/whj/java/jdk1.8.0 _ 25
Export JRE_HOME =/home/whj/java/jdk1.8.0 _ 25/jre
Export CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib
Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH: $ HOME/bin

5. After the first method fails, you must 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. Check that the configuration is successful: java-version

Information is configured successfully! (You may need to restart the instance once. You can restart the instance once and view the result again)

7. After the installation is successful, we can use an example to test it: in the/home/whj/directory, create the file hello. java. open the file and enter the following content.

public class hello{    public static void main(String args[]){        System.out.println("hello wrold");    }} 
8. Save and enter javac hello on the terminal. java (Note: The hello is created under the/home/whj/directory. java file. Otherwise, you must first go to the corresponding directory to run this command. You can first try the ls command in the terminal to list all files in the current directory)

9. If hello world is output, the configuration is complete,

10. The configuration is successful. The JDK environment has been set up.

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.