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     - Java Annotation Comments (Programming)

- Ubuntu prevent arp attacks (Linux)

- Linux System Getting Started Tutorial: How do you know Shell which is currently being used (Linux)

- CentOS 7.0 Experience with previous versions (Linux)

- Linux non-root user uses less than 1024 ports (Linux)

- MongoDB upgrade from 2.4.9 to 2.6.0 and PHP record of mongo extension upgrade from 1.4.5 to 1.5.1 (Database)

- Java implementation chain store binary tree (Programming)

- Make command Detailed Tutorial (Programming)

- Use Visual Studio to compile and use WinGDB remote debugging embedded Linux programs (Programming)

- Shell scripts quickly deploy Tomcat project (Server)

- Python 3.5 will support Async / Await Asynchronous Programming (Programming)

- Perl loop (Programming)

- Python Socket Network Programming (Programming)

- 30 minutes with your Quick Start MySQL Tutorial (Database)

- NIC configuration parameters under Linux (Linux)

- Linux System Getting Started Learning: Linux common log file (Linux)

- Beautiful start Ubuntu installation tool Duck Launcher 0.64.5 (Linux)

- SSL VPN SSL VPN access to security websites patron (Linux)

- Android memory optimization of the optimal load Bitmap (Linux)

- RPM package management under Linux (Linux)

 
         
  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 binlog resolve the garbage problem decryption (Database)
- RHEL7 system making use of OpenStack mirror (Linux)
- Talk about Java in the collection (Programming)
- Ordinary users how to use the firewall software (Linux)
- Verify the character set on MyCAT (Database)
- The formatted Linux hard drive and mount (Linux)
- CentOS yum source as the default setting methods in DVD (Linux)
- Oracle: RETURNING clause (Database)
- Python context managers (Programming)
- Linux partition command (Linux)
- Use SocketServer write a sockets program (Programming)
- Install Kali Linux via PXE network (Linux)
- A new method for Linux hidden files (Linux)
- Why you can have JavaScript string method (Programming)
- Linux System Getting Started Tutorial: How to find the maximum memory your system supports (Linux)
- Java Generics Introduction --HashMap summary (Programming)
- Quagga use authentication on strengthening BGP session security (Linux)
- Under CentOS using yum command to install the Task Scheduler crontab (Linux)
- Oracle local user login authentication fails ORA-01031 insufficient privileges (Database)
- Linux kernel source tree to establish load module hello (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.