A brief discussion on how to modify/set the environment variable JAVA_HOME under Linux

A brief discussion on how to modify/set the environment variable JAVA_HOME under Linux

1. Permanent modification, valid for all users

# vi /etc/profile

//Press [Shift + g] on the keyboard and add the following content at the end of the profile file:

JAVA_HOME=/usr/local/java/jdk1.7.0_25
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME JRE_HOME CLASSPATH
or export JAVA_HOME = /home/myuser/jdk1.7.0_03
export PATH = $JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#oracle related variables export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin:/bin:/usr/bin:/usr/sbin:/usr
/local/bin:/usr/X11R6/bin
export PATH=$ORACLE_HOME/bin:$PATH:/sbin/

[Note]: If you want the modification to take effect immediately, you must run #source /etc/profile

2. Permanent modification, valid for a single user

//Modify the .bash_profile file in the user directory $ vi /home/myuser/.bash_profile
//Add the following content at the end of the file export JAVA_HOME = /home/myuser/jdk1.7.0_03
export PATH = $JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

[Note]: If you want the modification to take effect immediately, you must also run #source /home/myuser/.bash_profile

3. Only valid for the current bash/shell

$ export JAVA_HOME = /home/myuser/jdk1.7.0_03
$ export PATH = $JAVA_HOME/bin:$PATH
$ export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

This is the end of this article about how to modify/set the environment variable JAVA_HOME under Linux. For more information about how to modify/set the environment variable JAVA_HOME under Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to modify the value of private final member variable in Java reflection
  • One-click setting of Java environment variables, instructions for viewing, modifying (overwriting and adding) in cmd
  • Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type exception
  • Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Transformer exception
  • Usage of Java generics and analysis of the acquisition process of T.class
  • Solution to the error "decompiled.class file bytecode version:52.0(java 8)" when IntelliJ IDEA introduces a third-party jar package or views the Java source code
  • A brief discussion on the difference between class name .class, class.forName(), getClass() in Java
  • Android Caused by: java.lang.ClassNotFoundException solution
  • How to modify .class file variables in Java

<<:  MySQL statement execution order and writing order example analysis

>>:  About WeChat Mini Program to implement cloud payment

Recommend

JavaScript Html to implement the mobile red envelope rain function page

This article example shares the specific code of ...

Sample code for batch deployment of Nginx with Ansible

1.1 Copy the nginx installation package and insta...

HTML Basic Notes (Recommended)

1. Basic structure of web page: XML/HTML CodeCopy...

Why does MySQL database index choose to use B+ tree?

Before further analyzing why MySQL database index...

Nest.js authorization verification method example

Table of contents 0x0 Introduction 0x1 RBAC Imple...

jQuery achieves the shutter effect (using li positioning)

This article shares the specific code of jQuery t...

SQL injection vulnerability process example and solution

Code example: public class JDBCDemo3 { public sta...

Vue uses openlayers to load Tiandi Map and Amap

Table of contents 1. World Map 1. Install openlay...

Vue implements a shopping cart that can change the shopping quantity

This article shares with you how to use Vue to ch...

Solution to the IP address not being displayed under Linux

Table of contents Preface Solution: Step 1 Step 2...

How to change the encoding of MySQL database to utf8mb4

The utf8mb4 encoding is a superset of the utf8 en...

Navicat remote connection to MySQL implementation steps analysis

Preface I believe that everyone has been developi...

JavaScript function syntax explained

Table of contents 1. Ordinary functions 2. Arrow ...