First, in Cd/usr, mkdir java.
Put the Java installation package into/usr/java and unzip it.
Verify Java.
$ java-version
If prompted, the following installation package contains it, but it is not installed. Is the reason that the environment variable is not configured.
(You can enter the Java decompression package inside the validation, it is feasible to indicate that the Java package is not a problem!) )
Configure the environment variable, vi/etc/profile add the following code at any location
#Set Java Environment
Export path= $PATH:/usr/java/jdk1.8.0_25/bin
Export classpath=.:/ Usr/java/jdk1.8.0_25/jre/lib
Save, restart Linux, then!
Add:
To view environment variables:
Echo $PATH
To configure a Java environment variable:
#Set Java Environment
Export path= $PATH:/usr/java/jdk1.8.0_25/bin
Export classpath=.:/ Usr/java/jdk1.8.0_25/jre/lib
Execute the above command! , but the terminal restart will fail.
(The environment variable is often modified in the/etc/profile file, where the content is modified to work for all users.)
Edit the environment variables using the Modify. bashrc file, which is useful only to the current user. )
Write these two commands to VI/ETC/BASH.BASHRC
Run: Source BASH.BASHRC, make settings effective! Can solve the problem of failure after restarting!
The name of the environment variable is generally capitalized
Show all environment variables $ env
Display environment variable HOME value $ echo $HOME
Env is an external command, program file/bin/env, used to list all environment variables and their assignments.
Export setting environment variables
echo display text, print text
Set is used to display local variables, displaying variables for the current shell, including variables for the current user
Configuring Java environment variables under Linux, so easy!!