官术网_书友最值得收藏!

Time for action – installing JDK and configuring the environment variables

To configure the JAVA_HOME and PATH variables, follow these steps:

Installing on a LINUX environment:

  1. Install JDK 1.7. You can go to the official Java website (www.java.com), download the installer file and then execute it in your operating system. Or you can execute the following commands in a terminal:
    shell> sudo add-apt-repository ppa:webupd8team/java
    shell> sudo apt-get update
    shell> sudo apt-get install oracle-java7-installer
  2. Write the following command in the terminal:
    shell> sudo gedit /etc/environment
  3. Add a line in this file that contains the following (or similar, depending on each environment):
    JAVA_HOME="/usr/lib/jvm/java-7-oracle"
  4. To the beginning of the value of the PATH variable, add the /usr/lib/jvm/java-7-oracle/bin: string.
    Note

    The separator for the PATH entries in Linux environments is ":".

  5. The /etc/environment file should look like this:
  6. Restart the session.

In Windows environments:

  1. Install JDK 1.7. Go to the official Java website (www.java.com), download the installer file, and then execute it in your operating system.
  2. Click on the Environment Variables... option:
  3. To add the JAVA_HOME system variable, click on the New... button that is found in the System variables section:
  4. This action will open a new window, where we must fill in the following values:
    • In Variable name:, type JAVA_HOME.
    • In Variable value:, type the path that corresponds to the JDK installation. For example, add a system variable with the name JAVA_HOME and complete its value with the corresponding path, say, C:\Program Files\Java\jdk1.7.0_04, as shown in the following screenshot:
  5. Click on OK to save the changes and exit.
  6. In the System variables section, select the PATH variable and click on the Edit... button.
  7. At the beginning of the value of the PATH variable, add the %JAVA_HOME%\bin; string.
  8. The separator for PATH entries in the Windows environment is ; as shown in the following screenshot:
  9. Press OK to save changes and exit.
  10. Restart your computer.

To confirm the correct installation in Linux as well as in Windows, we can execute the following command in a terminal:

shell> java -version

We should obtain a result similar to the following:

java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)
Note

In 2009, Oracle acquired Sun Microsystems, which gave Oracle Java technology the MySQL RDBMS and the Solaris operating system. This is why in Linux environments, the package corresponding to Java Version 1.6 is called sun-java6-jdk, and in Version 1.7, it's called oracle-java7-installer.

What just happened?

We installed JDK and configured the JAVA_HOME and PATH environment variables. Configuration was performed for both the Linux and Windows operating systems. We defined the JAVA_HOME environment variable that points to a local Java installation. We also added the Java bin directory to the PATH variable so that we can call Java from anywhere.

主站蜘蛛池模板: 邓州市| 钟山县| 岳阳市| 西林县| 来安县| 台中市| 邯郸市| 莆田市| 浪卡子县| 灵山县| 普兰县| 莲花县| 宣恩县| 抚远县| 台山市| 微博| 隆子县| 潍坊市| 罗定市| 敦化市| 建瓯市| 赤峰市| 家居| 玉屏| 泸溪县| 剑川县| 绥芬河市| 巍山| 甘洛县| 尼玛县| 客服| 荔浦县| 元阳县| 嘉义市| 银川市| 保山市| 潍坊市| 蛟河市| 望都县| 灵武市| 黄骅市|