How to set JAVA_HOME in Linux for all users
find /usr/lib/jvm/java-1.x.x-openjdk
vim /etc/profile
Prepend sudo if logged in as not-privileged user, ie.
sudo vim
- Press 'i' to get in insert mode
add:
export JAVA_HOME="path that you found"
export PATH=$JAVA_HOME/bin:$PATH- logout and login again, reboot, or use
source /etc/profile
to apply changes immediately in your current shell
Maven Java home configuration
As you can see in the documentation the JAVA_HOME
variable must point to the java installation path, not to the bin
folder.
Change it to C:\Program Files\Java\jdk1.8.0_131
Windows Subsystem for Linux not recognizing JAVA_HOME Environmental Variable
As Biswapriyo suggested, you should use WSLENV.
Open PowerShell. Then set
JAVA_HOME
to the path to your java installation.In your case, run
setx JAVA_HOME "D:\Program Files\Java\jdk-11.0.1"
You should see a message that says "SUCCESS: Specified value was saved".
- Then run
setx WSLENV "JAVA_HOME/p"
.
You should see the success message again.
- Type 'env' into your WSL bash prompt.
You should see JAVA_HOME
correctly set at this point.
Note: If step 2 doesn't work, you might want to changing the path to JAVA_HOME
to include the \bin
folder.
How to set Java environment path in Ubuntu
set environment variables as follows
Edit the system Path file /etc/profile
sudo gedit /etc/profile
Add following lines in end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Then Log out and Log in ubuntu for setting up the paths...
How do I fix maven error The JAVA_HOME environment variable is not defined correctly?
The SETX
command does not modify the current environment.
If you run the following batch file:
setx AAA aaa
echo AAA=%AAA%
It will print
AAA=
So your batch file is wrong. You have to use set
:
set AAA=aaa
See What is the difference between SETX and SET in environment variables in Windows.
How to set JAVA_HOME environment variable on Mac OS X 10.9?
If you're using bash, all you have to do is:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
If you're using zsh (which probably means you're running macOS Catalina or newer), then it should instead be:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.zshrc
In either case, restart your shell.
If you have multiple JDK versions installed and you want it to be a specific one, you can use the -v
flag to java_home
like so:
echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile
Related Topics
How to Imshow with Invisible Figure in Matlab Running on Linux
Why Can Back-Quotes and $() for Command Substitution Result in Different Output
Convert an Iso Date to Seconds Since Epoch in Linux Bash
How to Run Script Commands from Variables
How to Find Words from One File in Another File
Bash Store Output as a Variable
How to Create a Statically Linked Position Independent Executable Elf in Linux
What's the Difference Between ./Script.Sh and Bash Script.Sh
How to Set Process Group of a Shell Script
Bash 'Swallowing' Sub-Shell Children Process When Executing a Single Command
Write-Only Mapping a O_Wronly Opened File Supposed to Work
Platform Independent Resource Management
Can't Run Executable Linked with Libc
Intellij Idea Under Linux, No Such File or Directory on Main Class
Using <Linux/Types.H> in User Programs, or <Stdint.H> in Driver Module Code...Does It Matter