![]() Configuring the JAVA_HOME and PATH environment variables If I'm happy with the output from that, everything else can be derived from it. echo $(readlink -e `which java` | xargs -0 dirname) Once I've installed the openjdk version of the Java Development Kit on an Ubuntu machine, I use this procedure to create a JAVA_HOME environment variable that doesn't need to be changed after every version upgrade of the openjdk installation.įirstly, I issue a command to discover the directory in which the java executables are located for this java installation. PS: There should be no need to update the $PATH, as update-alternatives takes care of the link to /usr/bin/. To do it at machine level, and for all bourne shells, you need 2 steps:Īs your shell might not be set as interactive by default, you may want to do this also: Use this if you don't have permissions to do it at machine level. Here are the suggestions for both: only specific unix account or for all accounts (machine level). The correct way (and mandatory when you have more than one), is to detect what update-alternative is pointing to, and always use update-alternatives to switch active version. Correct way to set JAVA_HOME (and optionally JAVA_SDK, JAVA_JRE ) bashrc or some other place:Įxport JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64īut it's not healthy, as later on you may change the version. Install desired java version / versions using official ubuntu packages, which are managed using alternatives:Ībove answers are correct only when you have only one version for all software on your machine, and you can skip using update-alternatives. ![]() Once again you need to type the following command to activate the path settings immediately: # source /etc/profile Next setup PATH / JAVA_PATH variables as follows: export PATH=$PATH:/usr/java/jdk1.5.0_07/binĮxport PATH=$PATH:/usr/java/jdk1.5.0_07/bin To Set JAVA_HOME / PATH for all user, You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users: # vi /etc/profile Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and. Tip: Use the following command to find out exact path to which java executable under UNIX / Linux: $ which java Alternatively, type the following command to activate the new path settings immediately: $ source ~/.bash_profile Just logout and login back to see new changes. Set PATH as follows: export PATH=$PATH:/usr/java/jdk1.5.0_07/binįeel free to replace /usr/java/jdk1.5.0_07 as per your setup. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows: export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java Set JAVA_HOME as follows using syntax export JAVA_HOME=. ![]() To Set JAVA_HOME / PATH for a single user, Login to your account and open.
0 Comments
Leave a Reply. |