Где Java установлен на Mac OS X?
Я только что загрузил Java 7u17 на Mac OS 10.7.5 из здесь и затем успешно установил его. Чтобы выполнить Программирование JNI, мне нужно знать, где Java установлена на моем Mac.
Я думал, что внутри /Library/Java/JavaVirtualMachines/ папка, будет папка с именем 1.7.0.jdk или что-то, но потом я обнаружил, что папка пуста. Это было подтверждено управлением ls /Library/Java/JavaVirtualMachines/ в терминале. Я попытался найти его, чтобы узнать, был ли он установлен где-то еще, но похоже, это ничего не дает.
может кто-нибудь сказать мне, где Java установлен на моем Mac?
14 ответов
использовать /usr/libexec/java_home -v 1.7 команда на оболочке терминала, чтобы выяснить, где находится ваш домашний каталог java 1.7
Если вы просто хотите узнать домашний каталог вашей последней версии java, опустите версию. например, /usr/libexec/java_home -v
оказывается, что у меня на самом деле был установлен Java 7 JRE, а не JDK. Правильная ссылка для скачивания -здесь. После его установки, jdk1.7.0jdk отображается в каталоге JavaVirtualMachines.
можно использовать echo $(/usr/libexec/java_home) команда в вашем терминале, чтобы узнать путь, где устанавливается Java.
Если вы устанавливаете только JRE, он, кажется, помещается в:
используйте функцию поиска unix для поиска установленных javas.
структура пакетов Java Mac OS немного отличается от Windows. Не расстраивайтесь из-за этого, так как разработчику просто нужно установить PATH и JAVA_HOME .
так .bash_profile set JAVA_HOME и PATH Как ниже. Этот пример для Java 6:
попробуйте это, это простой способ найти java установлен путь в Mac OS X,
1 ) /библиотека i.e Macintosh HD / библиотека
2) нажмите на библиотеку, в которой мы найдем папку Java.
3) таким образом, окончательный путь
надеюсь, что это помощь для кого-то .
просто писать /Library/Java/JavaVirtualMachines/
в Go To Folder —> перейти в Finder
отредактировано: псевдоним текущей версии java — /Library/Java/Home
Я только что установил JDK для версии 21 Java SE 7 и обнаружил, что он установлен в другом каталоге от Java 6 от Apple. Он находится в /Library / Java. вместо этого в /System/Library / Java. Запуск /usr/libexec / java_home-V 1.7 против-V 1.6 подтвердит это.
я попробовал решение serkan, он нашел местоположение java 7 в OS X Mavericks. он находится в «/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/» но чтобы сделать его JDK по умолчанию, мне пришлось установить системную переменную JAVA_HOME .файл в домашнем каталоге на адрес «/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/» так что его и работает Теперь благодаря идее Серкана
Источник
Где установлена Java на Mac OS X?
Я только что загрузил Java 7u17 на Mac OS 10.7.5 из здесь и затем успешно установил его. Для того, чтобы сделать некоторые JNI программирования, мне нужно знать, где Java установлен на моем Mac.
Я думал, что внутри /Library/Java/JavaVirtualMachines/ папка, там будет папка под названием 1.7.0.jdk или что-то, но потом я обнаружил, что папка пуста. Это было подтверждено управлением ls /Library/Java/JavaVirtualMachines/ в терминале. Я попытался найти его, чтобы узнать, был ли он установлен где-то еще, но что, кажется, не будет ничего появляться.
может кто-нибудь, пожалуйста, скажите мне, где Java установлен на моем Mac?
14 ответов:
использовать /usr/libexec/java_home -v 1.7 команда на оболочке терминала, чтобы выяснить, где находится ваш домашний каталог java 1.7
Если вы просто хотите узнать домашний каталог вашей последней версии java, опустите версию. например, /usr/libexec/java_home -v
оказывается, что у меня на самом деле был установлен Java 7 JRE, а не JDK. Правильная ссылка для загрузки -здесь. После его установки, jdk1.7.0jdk появляется в каталоге JavaVirtualMachines.
вы могли бы использовать echo $(/usr/libexec/java_home) команда в вашем терминале, чтобы узнать путь, где устанавливается Java.
Если вы устанавливаете только JRE, кажется, что он находится по адресу:
используйте функцию unix find для поиска установленных javas.
структура пакета Java Mac OS немного отличается от Windows. Не расстраивайтесь за это, так как разработчику просто нужно установить PATH и JAVA_HOME .
так .bash_profile set JAVA_HOME и PATH Как ниже. Этот пример для Java 6:
попробуйте это, это простой способ найти java установлен путь в Mac OS X,
1 ) / Library i. e Macintosh HD / Library
2) нажмите на библиотеку, в которой мы находим папку Java.
3) так что окончательный путь
надеюсь, что это помощь для кого-то .
просто писать /Library/Java/JavaVirtualMachines/
в перейти к папке — > перейти в Finder
отредактировано: псевдоним для текущей версии java-это /Library/Java/Home
для получения дополнительной информации:ссылка
Я только что установил JDK для версии 21 Java SE 7 и обнаружил, что он установлен в другом каталоге от Apple Java 6. Он находится в / Library / Java. а не в /System/Library / Java. Запуск /usr/libexec / java_home-V 1.7 против-V 1.6 подтвердит это.
я попробовал решение Серкана, он нашел местоположение java 7 на OS X Mavericks. он находится в «/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/» но чтобы сделать его JDK по умолчанию, мне пришлось установить системную переменную JAVA_HOME .файл в домашнем каталоге на адрес «/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/» так что его и работает сейчас благодаря идее Серкана
Источник
What is path of JDK on Mac ? [duplicate]
Im using Mac only at work and I need to set JAVA_HOME to proper path of JDK. I downloaded JDK, installed it and now I can’t find it anywhere. I was looking at the internet for the solution, but there is no folder Libraries/Java.
5 Answers 5
The location has changed from Java 6 (provided by Apple) to Java 7 and onwards (provided by Oracle). The best generic way to find this out is to run
This is the natively supported way to find out both the path to the default Java installation as well as all alternative ones present.
If you check out its help text ( java_home -h ), you’ll see that you can use this command to reliably start a Java program on OS X ( java_home —exec . ), with the ability to explicitly specify the desired Java version and architecture, or even request the user to install it if missing.
A more pedestrian approach, but one which will help you trace specifically which Java installation the command java resolves into, goes like this:
if that gives you something like /usr/bin/java , which is a symbolic link to the real location, run
On my system, this outputs
and therefrom you can read the Java home directory;
if usr/bin/java points to another symbolic link, recursively apply the same approach with
An important variation is the setup you get if you start by installing Apple’s Java and later install Oracle’s. In that case Step 2 above will give you
and that particular java binary is a stub which will resolve the actual java command to call by consulting the JAVA_HOME environment variable and, if it’s not set or doesn’t point to a Java home directory, will fall back to calling java_home . It is important to have this in mind when debugging your setup.
Источник
What is the path to the JRE file?
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
6 Answers 6
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.
In Mac you can find Java JRE’s installed in the following folders
After installing the latest JRE8 (as of today update 131), do the following :
In your .bash_profile add the following
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:
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/
If you installed jre by dmg.
You can find your «java» at
and you can check version by command:
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
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.
Источник
Where is JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)?
Java is an optional package on the latest versions of macOS.
Yet once installed it appears like the JAVA_HOME environment variable is not set properly.
26 Answers 26
With the Java optional package or Oracle JDK installed, adding one of the following lines to your
/.bash_profile file will set the environment variable accordingly.
Note: If you installed openjdk on mac using brew, run sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk for the above to work
Update: added -v flag based on Jilles van Gurp response.
/usr/libexec/java_home is not a directory but an executable. It outputs the currently configured JAVA_HOME and doesn’t actually change it. That’s what the Java Preferences app is for, which in my case seems broken and doesn’t actually change the JVM correctly. It does list the 1.7 JVM but I can toggle/untoggle & drag and drop all I want there without actually changing the output of /usr/libexec/java_home .
Even after installing 1.7.0 u6 from Oracle on Lion and setting it as the default in the preferences, it still returned the apple 1.6 java home. The only fix that actually works for me is setting JAVA_HOME manually:
At least this way when run from the command line it will use 1.7. /usr/libexec/java_home still insists on 1.6.
Update: Understanding Java From Command Line on OSX has a better explanation on how this works.
is the way to do it. Note, updating this to 1.8 works just fine.
For me, Mountain Lion 10.8.2, the solution most voted does not work. I installed jdk 1.7 via Oracle and maven from homebrew.
My solution is from the hadoop-env.sh file of hadoop which I installed from homebrew, too. I add the below sentence in
/.bash_profile, and it works.
This solution also works for OS X Yosemite with Java 1.8 installed from Oracle.
None of the above answers helped me. I suppose all the answers are for older OS X
For OS X Yosemite 10.10, follow these steps
Use your favorite text editor to open:
Add the following line in the file and save it ( : followed by «x» for vim):
Then in the terminal type the following two commands to see output:
In the second line, you are updating the contents of .bash_profile file.
Update for Java 9 and some neat aliases.
Note, that for the latest version it is 9 and not 1.9 .
Set active Java:
Some additional alias to switch between the different versions:
Test in terminal:
EDIT: Update for Java 10
EDIT: Update for Java 11
The above didn’t work for me with Amazon’s EC2 tools, because it expects bin/java etc. underneath JAVA_HOME . /System/Library/Frameworks/JavaVM.framework/Home did work.
For OS X you can do:
On Mac OS X Lion, to set visualgc to run, I used:
The following worked for me. I’m using ZSH on OSX Yosemite with Java 8 installed.
The following command /usr/libexec/java_home emits the path to JDK home:
A better (more upgradable) way is to use the following:
This should work with AWS also since it has bin underneath Home
Newer Oracle JVMs such as 1.7.0_21-b12 seem to install here:
for macOS Mojave 10.14.1 and JAVA 11.0.1 I set the profile as
key in terminal this to confirm:
This makes it very easy to switch between J6 and J7
I Had to explicitly set it to the exact path on my Macbook air .
- try to echo $JAVA_HOME (if it’s set it’ll show the path), if not, try to search for it using sudo find /usr/ -name *jdk
- Edit the Bash p with — sudo nano
/.bash_profile
I am running MACOS MOJAVE — 10.14.2 (18C54) on a Macbook Air with JAVA 8
For Mac OS X 10.9 I installed the latest version of JRE from Oracle and then reset the JAVA_HOME to /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home.
I am sure there is a better way but got me up and running.
hbrien$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
OSX Yosemite, ZSH, and Java SE Runtime Environment 8, I had to:
$ sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands /System/Library/Frameworks/JavaVM.framework/Versions/Current/bin
/.zshrc change JAVA_HOME to export JAVA_HOME=»/System/Library/Frameworks/JavaVM.framework/Versions/Current»
Got the same issue after I upgrade my Mac OS and following worked for me:
Add/update the line for JAVA_HOME: export JAVA_HOME=»/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home»
/.bash_profile or open a new terminal
I think the jdk version might differ, so just use the version which you have under /Library/Java/JavaVirtualMachines/
If you are in need to have multiple versions of JDK under Mac OS X (Yosemite), it might be helpful to add some scripting for automated switching between them.
What you do is to edit your
/.bash_profile and add the following:
What the script does is to first remove other JDK versions in the PATH so that they won’t interfere with our new JDK version. Then it makes some clever use of /usr/libexec/java_home which is a command that lists installed JDK versions. The -v argument tells java_home to return the path of the JDK with the supplied version, for example 1.7. We also update the PATH to point to the bin directory of the newly found JAVA_HOME directory. At the end we can simply execute the function using
which selects the latest installed JDK version of the 1.7 branch. To select a specific version you can simply execute
instead. Run /usr/libexec/java_home -V to get more details on how to choose versions.
Источник