Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux System Getting Started Tutorial: How to automatically set the JAVA_HOME environment variable on Linux     - Cobbler automatic mass deployment of CentOS 6 and CentOS 7 (Linux)

- Linux system security (Linux)

- Docker installation under CentOS7 (Linux)

- Spring Integration ehcache annotation implement the query cache and cache update or delete instant (Programming)

- Ubuntu 14.04 LTS next upgrade gcc to gcc-4.9, gcc-5 version (Linux)

- CentOS 7 version how to achieve the power to start the graphical interface (Linux)

- Security measures under Unix multi-user operating system (Linux)

- The basic principles for the protection of a good linux server security (Linux)

- Chkconfig set boot start under Linux (Linux)

- How Linux system password security guarantee (Linux)

- PL / SQL data types (Database)

- How to install CentOS CentOS web page (Server)

- iOS constants, variables, properties and characteristics (Programming)

- Number JavaScript type system (Programming)

- CentOS 6.5 installation Python3.0 (Linux)

- mysql_config_editor encryption and decryption of the new features of MySQL realization (Database)

- Linux, C programming language library file handling and preparation of Makefile (Programming)

- PostgreSQL using the system cache to improve operational efficiency (Database)

- Circular list of Java programming (Programming)

- MongoDB slice simple example (Database)

 
         
  Linux System Getting Started Tutorial: How to automatically set the JAVA_HOME environment variable on Linux
     
  Add Date : 2018-11-21      
         
         
         
  Question: I need on my Linux machine to compile Java programs. For this reason I have installed JDK (Java Development Kit), and now I'm trying to set the JAVA_HOME environment variable to point to the installed JDK. About setting JAVA_HOME environment variable on Linux, what way is the most respected?

Many Java programs or Java-based integrated development environment (IDE) will need to set the JAVA_HOME environment variable. This variable should point to the Java Development Kit (JDK) or Java Runtime Environment (JRE) installation directory. JDK includes not only all the JRE provided also with additional binaries and library files (such as compilers, debuggers and JavaDoc documentation generator) for compiling Java programs. JDK is used to build Java programs, if you just run a Java program has already been built, a JRE alone is sufficient.

When you are trying to set JAVA_HOME environment variable, JAVA_HOME variable troublesome thing that needs to change in accordance with the following: (1) Have you installed the JDK or JRE; (2) which version you have installed; (3) you have installed It is Oracle JDK or Open JDK.

So whenever your development environment or the runtime environment changes (for example, JDK update version), you need to adjust the JAVA_HOME variable according to the actual situation, and this approach is tedious and inefficient.

The following export command can automatically set the JAVA_HOME environment variable for you, without regard to the above factors.

If you are installing the JRE:

export JAVA_HOME = $ (dirname $ (dirname $ (readlink -f $ (which java))))
If you installed JDK:

export JAVA_HOME = $ (dirname $ (dirname $ (readlink -f $ (which javac))))
Depending on your situation, the above command will write a ~ / .bashrc (or / etc / profile) file, it will set the JAVA_HOME variable permanently.

Note that since java or javac can build multiple levels of symbolic links, for "readlink -f" command is used to get their real execution path.

For example, if you are installing Oracle JRE 7, then the above-described first export order is automatically set JAVA_HOME as follows:

/ Usr / lib / jvm / java-7-oracle / jre
If you are installing the Open JDK version 8, the second export command to set the JAVA_HOME:

/ Usr / lib / jvm / java-8-openjdk-amd64


In short, these export commands you to reinstall / upgrade your JDK / JRE, or replace the automatic update JAVA_HOME variable default Java version. You no longer need to manually adjust it.
     
         
         
         
  More:      
 
- MySQL Statistics (Database)
- Oracle 12C RAC optimizer_adaptive_features cause of data into overtime (Database)
- PF_RING 6.0.2 compiled and installed on Redhat 6.3 x86_64 (Linux)
- Bash command substitution (Programming)
- Make Linux more secure server tips (Linux)
- Use mysqldump backup performed MariaDB (Database)
- Hadoop vs spark (Server)
- Linux / Unix system-level IO (Linux)
- iSCSI + multipath achieve DM multipath storage (Server)
- CentOS 7 source code to compile and install Nginx process record (Server)
- Offline (local) Yum source structures (Linux)
- Use libcurl library download url image (Programming)
- Increase Linux system security --chattr (Linux)
- How to make Linux a non-root user uses less than 1024 ports (Linux)
- How to Install lightweight Budgie desktop on Ubuntu 14.04 (v8) (Linux)
- How to install Bugzilla 4.4 on Ubuntu / CentOS 6.x (Linux)
- CentOS6.0 successful installation and configuration OpenCV (Linux)
- Ubuntu install virtual machine software VirtualBox 4.3.10 (Linux)
- Wireless LAN security solutions (Linux)
- Linux ban single-user mode to enhance system security (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.