Find java installation path

finding location java_home in Windows 10

I need help finding the location of my java_home/bin, or if it even exists. If it doesn’t, what more do I need to install? I am following some installation directions, and one of the steps says:

Ensure that the Java Runtime Environment (JRE) is installed on the computer and that the java_home/bin directory is defined in the system path.

I can’t even find the path of java_home. Disregarding the directions for other OS, this is the closest I’ve come to finding something helpful. However, when I type the prescribed command, echo %java_home% it just returns %java_home% as a string, percent signs and all. When I try % java -version down further in the page, it tells me %java isn’t a recognized command, program, or batch file. I have Java 8 Update 60 installed, I can see it in my list of programs I can uninstall. From the quote though, I have in mind that if I have a JRE installed, then java_home\bin exists. However, I’ve had File Explorer search very nearly the entire computer, and found nothing.

2 Answers 2

I need help finding the location of my java_home/bin

  • «Start» > «Control Panel» > «Java».
  • Select «Java» tab. enter image description here
  • Click «View»
  • Look in the «Path» column for version of the JRE you have installed. enter image description here

In the above example the «Path» contains:

JAVA_HOME should point to the root directory of the Java installation, so in this case:

And the PATH should contain JAVA_HOME\bin , in this case:

From a command prompt we can set these values using the following commands:

setx JAVA_HOME C:\apps\jdk setx PATH C:\apps\jdk\bin;%PATH% 
  • Modify the above commands as appropriate for your Java installation.
  • These are System not User environment variables.

Источник

How to find path to java?

That tells the command java resides in /usr/bin/java.

$ ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 2009-01-15 18:34 /usr/bin/java -> /etc/alternatives/java 

So, now we know that /usr/bin/java is actually a symbolic link to /etc/alternatives/java .

Dig deeper using the same method above:

$ ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 31 2009-01-15 18:34 /etc/alternatives/java -> /usr/local/jre1.6.0_07/bin/java 

So, thats the actual location of java: /usr/local/jre.

Читайте также:  Символ лупы в css

You could still dig deeper to find other symbolic links.

export JAVA_HOME=$(dirname $(dirname $(update-alternatives --list javac))) 

To make this seemingly over done setting clearer, on my Ubuntu linux machine with open JDK 8 installed:

$ update-alternatives --list java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java $ update-alternatives --list javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 

but what we need is the path to the directory containing bin of the JDK. So ask for the location of javac and then use dirname twice.

See man update-alternatives for more.

Be aware of the possibility that people might have two JDK’s installed. To always use the first one as your JAVA_HOME you can use head : JAVA_HOME=$(dirname $(dirname $(update-alternatives —list javac 2>&1 | head -n 1)))

Starting from January 2019, the licensing model for Oracle Java has changed. PPAs such as ‘ppa:webupd8team/java’ used in many Java installation tutorials now become unavailable.

Here I would like to share how I installed Java 8 on Ubuntu 16.04, and set the Java path in terminal.

Installation

I followed the instruction on the official documentation to install Java with .tar.gz

Path setting

The instruction is also from the official documentations. The steps to set up Java path are much simpler here.

After performing all the steps, restart the terminal and run ‘java -version’ to verify installation.

Источник

How to find path where jdk installed?

I’ve installed jdk1.7.0.rpm package in RHEL6.
Where I do find the path to execute my first java program?

Hi, Mohammad. It’s not a stupid question, but one that has been answered in several places already — like this or this question.

Just an PS: on MacOS, Java is usually installed at ‘/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home’, where the version number could be different.

4 Answers 4

For your first java program read this tutorial:

Note these commands give different results. If you are interested in the non-symlink path use whereis java.

I don’t really think this answers the question. The java binary gets installed with the JRE, but if you’re doing development you need JDK, which isn’t necessarily installed in which java (which in my case is /usr/bin).

On RHEL7, you can use locate :

and it led me to the /usr/lib/jvm/ directory which contained the directories:

java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/ jre/ jre-1.8.0/ jre-1.8.0-openjdk/ jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/ jre-openjdk/ 

Each of these contain a bin/java

To find the full path of the symbolic link use:

This gave me mostly JDK6 even though java -version gave me 1.8. There was one link to the JDK8 folder near the top.

Читайте также:  Java зачем абстрактному классу конструктор

You can list the installed files with

You will see somewhere a bin directory with java executable

But if the JDK RPM was correctly installed you should already find java in you path.

javac MyFirstJavaClass.java 

and if everything compiles

(If you didn’t change anything the current directory . should already be in your class path)

Since this question is RPM specific, rpm is the way to get started (as answered by @Matteo).

-q is short for --query -l is short for --list 
rpm -ql jdk1.8.0_20 | grep "jdk1.8.0_20/bin$" 

Knowing this may be desirable for setting a user or application’s $JAVA_HOME variable. This is often needed when a system has multiple versions of java installed, or multiple distributions of java installed, such as OpenJDK and Oracle/Sun.

$JAVA_HOME Example

In the ~/.bash_profile , or related file ( .bashrc , .zshrc , .cshrc , setenv.sh ), something similar to the below may be used.

JAVA_HOME='/usr/java/jdk1.8.0_20' export JAVA_HOME PATH="$JAVA_HOME/bin:$PATH" export PATH 

If you would like more control over where Java gets installed, such as in /opt , then the tarball can be used instead of the RPM file.

Other similar questions, are asking about how to find any binary or file, in the general case.

Источник

Find Java Location in Windows

Find Java Location in Windows

  1. Find Java Location Using Command where java
  2. Find Java Location Using Command set JAVA_HOME
  3. Find Java Location Using Command dir /b /s java.exe
  4. Find Java Location Using Command gcm -All java in Windows PowerShell

Today, we will see how to find out where Java is located in Windows. There are multiple ways and commands to do this; we will check out various commands that return the Java location windows.

Find Java Location Using Command where java

The most commonly used command to get the current location of Java in Windows is where java . This is a Windows command that works just like the whereis command in Linux Operating System. The where command is used to display the location of the executable. It usually uses a search pattern.

As shown below, when we run the command where java in the command line of Windows, it returns the location of java.exe .

C:\User\.jdks\openjdk-15.0.1\bin\java.exe 

Find Java Location Using Command set JAVA_HOME

The next technique to get the location of Java in Windows is to use the command set JAVA_HOME . In Windows, the path of Java or JDK is stored in the environment variables. The location is stored in the variable named PATH , a list of directories that can be used to access certain programs like Java directly without writing the whole path.

Читайте также:  What is event object in javascript

We can set the path of Java by the command set JAVA_HOME and then specify the path. But if the value is already set, it will return the path set to the variable JAVA_HOME . It completes our goal as this is the directory in which Java is located.

C:\Users\Rupam Saini>set JAVA_HOME 
JAVA_HOME=C:\Users\Rupam Saini\.jdks\openjdk-15.0.1 

Find Java Location Using Command dir /b /s java.exe

The dir command shows all the folders and sub-folders in the current location. We can use this command to get the locations of Java as there might be more than one executable of Java in a single Windows machine as some programs use their own Java environment.

We use the dir command with three parameters, first is /b that displays only the directory path without any extra details. In contrast, the /s parameter lists every occurrence of the specified file in the current directory and subdirectories, and at last, the execute name that is java.exe .

C:\User\.jdks\openjdk-15.0.1\bin\java.exe C:\User\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2020.3\jbr\bin\java.exe 

Find Java Location Using Command gcm -All java in Windows PowerShell

In all the examples in this tutorial, we use the traditional command-line,, but this method requires the Windows PowerShell, a command-line but with advanced capabilities. In PowerShell, we use the gcm command that is short for get-command . It returns all the commands in the machine.

We use gcm with two parameters; the first is -All that shows all the instances of the command in the current machine, and the second parameter is the command name. In our case, the command name is java . In return, it outputs some details about the command like the Command Type, the name of the executable executed on command, the version, and the executable source. The source is where Java is located.

CommandType Name Version Source ----------- ---- ------- ------ Application java.exe 15.0.1.0 C:\User\.jdks\openjdk-15. 

Rupam Saini is an android developer, who also works sometimes as a web developer., He likes to read books and write about various things.

Источник

Оцените статью