22

I am looking for the path the the JRE file on Mac OS X 10.6.8. Or is there no such file? Is JRE just slang for an idea or concept? Java Runtime Environment is a real thing.

Does it have a file? I am installing something that asks for the path to the JRE file http://www.boonex.com/trac/dolphin/wiki/RayMediaServerInstallation

Vivoco
  • 221
  • 1
  • 2
  • 3
  • This link will help you [How install a specific jdk on Mac OS X?](http://stackoverflow.com/questions/1577014/how-install-a-specific-jdk-on-mac-os-x) **AND** [JRE 7 Installation for Mac OS X](http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jre.html) – Smit Jan 19 '13 at 02:41
  • To update this for future use: If you need Java for development, you want the JDK not the JRE. I recently found a great JDK manager at https://www.jenv.be/. Hope this helps. – Mike S. Oct 20 '22 at 15:42

7 Answers7

22

On the mac, set JAVA_HOME to "/System/Library/Frameworks/JavaVM.framework/Home"

The JRE is not a file. The JRE is the java runtime environment and is made up of many files. The convention for java is to specify the JAVA_HOME. That is a directory containing a bin folder.

Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
Aris Bartee
  • 728
  • 8
  • 12
  • 2
    -1 - This does not answer the Question that was asked. He is explicitly asking about a "file" ... not a directory. – Stephen C Jan 22 '14 at 01:11
  • He explicitly asked for the path the to the JRE. What I originally did not give was explanation of what the JRE is. Or do you think I shouldn't have answered the question at all. – Aris Bartee Feb 07 '14 at 05:47
  • 3
    In addition, Oracle stores Java 8 (JRE & SDK 1.8) in /Library/Java/JavaVirtualMachines/. Reference this answer: http://stackoverflow.com/a/13918476/447949 – yters May 19 '14 at 02:48
  • This worked for me to (OS X 10.10.2). This should be marked as the correct answer. – apanloco Feb 24 '15 at 15:24
  • @StephenC Since when is a directory not a file? – Theodore Norvell Aug 15 '17 at 20:23
  • Since the 1970's. Or earlier. But certainly the 1970's. What happens when you try to run "rm" on a directory or "rmdir" on a file on a Linux / UNIX system? Now ... both directories and files have paths, and the syntax for directory and file paths is (almost) the same. – Stephen C Aug 16 '17 at 00:55
  • @ArisBartee - Actually, I think you should have at least have pointed out that the OP had messed up his terminology, and misread the installation documentation to boot!. I suspect that his poor understanding of the terminology is the real reason he misunderstood the documentation. (Alternatively, if he really thinks / thought the JRE is a file ... then that needs to be corrected too ... for the same reason.) – Stephen C Aug 16 '17 at 02:06
21

In Mac you can find Java JRE's installed in the following folders

/Library/Java/JavaVirtualMachines/

Example /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home.

sam
  • 568
  • 1
  • 8
  • 16
19

After installing the latest JRE8 (as of today update 131), do the following :

In your .bash_profile add the following

export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'

Then add that to your path export PATH=$PATH:$JAVA_HOME. Save and open a new terminal. Type java -version. You should see output like this:

->java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Mike S.
  • 2,048
  • 1
  • 32
  • 55
  • 4
    on a related note, if you need a path to the JDK (located elsewhere by default installation), I found this export statement avoids hard-coding the path: `export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"` Make sure you edit the version number if needed. – Mike S. Jun 14 '17 at 18:04
  • UPDATE: Here's what I have now in my `.zshrc` config file # To find JAVA_HOME, run "$(dirname $(readlink $(which javac)))/java_home" export JAVA_HOME=`/usr/libexec/java_home --version 16` #keep backticks – Mike S. May 22 '21 at 16:37
4

On El Capitan with Java 8, here is a way to check the path of jre. Go "System Preference/Java", then go third tab "Java" and click "View". Then you can get the JRE path, which is /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/

Skatox
  • 4,237
  • 12
  • 42
  • 47
Genie Tsai
  • 49
  • 4
4

Run /usr/libexec/java_home in a terminal. It will return the path that corresponds to $JAVA_HOME for your Mac's default Java installation. Attach /jre to this path to get the Java runtime environment (JRE) path.

Example:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home

JRE would be /Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/jre

To verify:

$ ls -al /Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/jre
total 552
drwxr-xr-x  10 root  wheel     340 Apr  2  2019 .
drwxr-xr-x  15 root  wheel     510 Apr  2  2019 ..
-r--r--r--   1 root  wheel    3244 Apr  2  2019 COPYRIGHT
-r--r--r--   1 root  wheel      44 Apr  2  2019 LICENSE
-r--r--r--   1 root  wheel      46 Apr  2  2019 README
-rw-r--r--   1 root  wheel  112748 Mar 14  2019 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r--   1 root  wheel  149725 Apr  2  2019 THIRDPARTYLICENSEREADME.txt
-r--r--r--   1 root  wheel     955 Apr  2  2019 Welcome.html
drwxr-xr-x  13 root  wheel     442 Apr  2  2019 bin
drwxr-xr-x  98 root  wheel    3332 Apr  2  2019 lib

This also works with any OpenJDK installation:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Versions

If you have multiple JREs or JDKs installed, you can obtain $JAVA_HOME for a specific version using the -v option:

$ % /usr/libexec/java_home -v 11  
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Tipp

To set the JAVA_HOME environment variable, use

$ export JAVA_HOME=`/usr/libexec/java_home`
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home
not2savvy
  • 2,902
  • 3
  • 22
  • 37
2

If you installed jre by dmg.

You can find your "java" at

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

and you can check version by command:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

Nico
  • 403
  • 3
  • 8
1

The /System/Library/Frameworks/JavaVM.framework/Home answer used to be correct.

With Oracle Java 8 (and later?) on MacOSX Sierra the /System/Library/Frameworks/JavaVM.framework/Home doesn't exist.

The answer for /Library/Java/JavaVirtualMachines/ is much closer. For the JDK at /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Content/Home, for instance, just add /jre to the end of that path for the JRE.

Tom
  • 1,387
  • 3
  • 19
  • 30
Steve Harris
  • 306
  • 2
  • 4