码迷,mamicode.com
首页 > 编程语言 > 详细

Instructions Set JAVA_HOME System-Wide

时间:2014-10-28 23:29:22      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   color   os   ar   java   for   sp   

Instructions

  1. Set JAVA_HOME System-Wide

    • 1

      Start a root terminal session and then change directories to the /usr/lib/jvm folder. If you prefer, you can also log in to your system as root.

    • 2

      Display the folder‘s contents by typing the following command at the Bash shell prompt and then pressing "Enter:"

      ls -l

      The listing will show several symbolic links and a single folder that contains your Java package files. The Java folder installed on CentOS 7 systems may have a name resembling the following:

      java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

      The full path to this folder, however, will be:

      /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

    • 3

      Type the Bash shell Exportbubuko.com,布布扣 command that will set the $JAVA_HOME variable to the Java folder‘s full path and then press "Enter." Your command should resemble the following:

      export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

      If you type "echo $JAVA_HOME" (without the quotes) at the command line and press "Enter", the shell will display the JAVA_HOME path. The path change will be lost when you reboot, however, unless you add the change to the system profile located in the /etc folder.

    • 4

      Switch directories to /etc and then open the "profile" text file using an editor like Vi, Emacs or Nano. The profile text file contains system-wide bash shell commands, parameters and variable available to all users.

    • 5

      Scroll to a blank line near the bottom of the file, type the same Export command you entered at the shell prompt, save the file and then exit your editor. When you or another user logs in to a CentOS session, the JAVA_HOME variable will be set.

    JAVA_HOME for Single Users

    • 6

      Launch the file manager and then navigate to the /usr/lib/jvm folder. The file manager should display the icons for one folder and several symbolic links.

    • 7

      Select the folder and then press "Ctrl-C" to copy it to the clipboard. One item the clipboard will contain is the full directory path to the Java folder.

    • 8

      As a normal, non-root user, launch Gedit and then open the ".bash_profile" text file located in your Home folder. Settings included in the .bash_profile are set every time you log in to your system.

    • 9

      Click a blank line near the bottom of the file and then press "Ctrl-V" to paste Java folder‘s full path. The pasted line should resemble the following:

      file:///usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

      To put the path in a format you can use, however, delete the "file://" section. The result should resemble the following

      /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

    • 10

      Add the Bash shell export command to this line that assigns the path to $JAVA_HOME, save your changes, and then exit Gedit. The final path command in your .bash_profile should resemble the following line:

      export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64

    • 11

      Log out of your CentOS session and then log back on set the $JAVA_HOME variable to Java‘s current location.



Read more : http://www.ehow.com/how_8424526_set-java-home-centos.html

Instructions Set JAVA_HOME System-Wide

标签:style   http   io   color   os   ar   java   for   sp   

原文地址:http://www.cnblogs.com/lkzf/p/4058035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!