Open File Explorer, click This PC in the left panel, then navigate to C:\Program Files\Java. The directory you’re looking for should have the name of the JDK version, such as C:\Program Files\Java\jdk-19. If you installed the JRE instead of the JDK, you’ll have something like C:\Program Files\Java\jre1. 8. 0_351 instead. You can also open the command prompt and run the command wmic product where “Name like ‘%%Java%%’” get installlocation,Name. This will tell you the full path of the JDK, even if you haven’t yet set JAVA_HOME.
Press the Windows key on your keyboard and type advanced system. Click View advanced system settings in the search results.
If you have multiple installations of the JDK and want to change JAVA_HOME to your new installation, select the current JAVA_HOME user variable and click Edit… instead.
If you have multiple installations of the JDK and want to change JAVA_HOME to your new installation, select the current JAVA_HOME user variable and click Edit… instead.
If you’re editing the current JAVA_HOME path, you’ll already have JAVA_HOME here. So, you can skip this step.
If you’re adding a second path to JAVA_HOME, just type a semicolon (;) after the first path, then enter the second path. If you’re replacing an old JAVA_HOME path, just delete the current path and enter the new one.
If you want other users on this PC to be able to access Java binaries from the command line, repeat this step for the “Path” variable under “System variables” as well.
Click the New button at the top. Enter the full path to the JRE or JDK with \bin at the end. For example, C:\Program Files\Java\jdk-19\bin or C:\Program Files\Java\jre1. 8. 0_351\bin. Click OK.
You won’t need to restart your computer for the changes to take effect, but you will need to relaunch any apps that were trying to access Java. Open a new command prompt window and run the command echo %JAVA_HOME% to display the new path to JAVA_HOME. Make sure this is a new command prompt window. If you still have the same window open, the command will fail because it doesn’t have the new environment variables.
If you have more than one Java installation and want to see the paths to all of them, use /usr/libexec/java_home -V instead.
Type cd ~ and press Return. Type open . zshrc and press Return. This should open the file in a text editor. If the file is not found, type echo > . zshrc and press Return. Then, run open . zshrc again.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17. 0. 1. jdk/Contents/Home Replace /Library/Java/JavaVirtualMachines/jdk-17. 0. 1. jdk/Contents/Home with the full path to the /Contents/Home directory of your Java installation if it’s different. export PATH=$JAVA_HOME/bin:$PATH Save the file and exit the text editor when you’re finished.
If you had any other windows open that were attempting to find Java binaries, close and reopen them. Shopping for PC accessories or office supplies? Check out our coupon site for Staples discounts or our coupon site for Office Depot.
This method will work in just about any version of Linux, including Ubuntu and Redhat.
This method will work in just about any version of Linux, including Ubuntu and Redhat.
readlink -f which javac If that doesn’t work, try running update-alternatives –list java.
If neither of these commands works, run whereis java, which will usually result in a symbolic link like /usr/bin/java.
Once you get the directory, find out where it links using ls -la /bin/java.
If that points you to another directory, e.
g.
, /etc/alternatives/java, run ls -la /etc/alternatives/java.
At that point, you should see a much longer directory, which is actually the home to the Java binaries.
For example, usr/lib/jvm/java-11-openjdk-arm64/bin/java.
This is the directory you want.
echo “export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64” » ~/. bashrc echo “export PATH=$PATH:$JAVA_HOME/bin” » ~/. bashrc
At this point, you can run echo $JAVA_HOME to see the location of Java on your system.