Не удалось завершить операцию unable to locate a java runtime
You’re now watching this thread and will receive emails when there’s activity. Click again to stop watching or visit your profile/homepage to manage your watched threads.
You’ve stopped watching this thread and will no longer receive emails when there’s activity. Click again to start watching.
I run Flutter in VS Code, and have been having no issues until today. All of a sudden I cannot build to Android. I've been building to 3 different Android devices (1 emulator; 2 devices (one USB; one wireless)) since I got my MBP (came with Big Sur) a couple months ago. Today it can't find Java.
Research says to check the Java icon in the System Preferences. But there is no Java icon in my System Preferences.
I also tried a different project via Android Studio, and it says the same thing. But I've BEEN building to Android, so I'm completely confused why today it all of a sudden can't find Java.
When I type which java or which javac they both point to /usr/bin/java and /usr/bin/javac . But typing java -version or /usr/bin/java -version gives that same error.
I went to Oracle, but they mention about costs. And this again makes me wonder. why am I even here?? Where did my Java go?
I also don't surf the web or download/install stuff on my Mac. I only do Flutter development on the Mac.
So do I just not think about how it disappeared, and go ahead and just install the JRE or JDK from Oracle? Or is there a way to tell the Mac to "please fix this"?
Thanks for any insights. -Keith
Helpful answers
Make sure the Java you have installed is not subject to the problems of Flashback.
Jun 18, 2012 5:24 AM
I'd advise you to stop customizing permissions and trashing system files. Open Applications > Utilities > Java Preferences.app and check the Enable applet plugin and Web Start applications box. Check the Java SE 6 (System) JVM's and close the application.
Jun 18, 2012 7:30 AM
There’s more to the conversation
Loading page content
Page content loaded
Make sure the Java you have installed is not subject to the problems of Flashback.
Jun 18, 2012 5:24 AM
I download it from Apple too, same file.
Problem could be path problem of javaws
TigreDARK:Home XXXXXXX$ /usr/libexec/java_home
TigreDARK:Home XXXXXX$ cd /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
TigreDARK:Home XXXXXX$ pwd
TigreDARK:Home XXXXX$ ls
bin bundle include lib man
TigreDARK:Home XXXXXX$ cd bin
TigreDARK:bin XXXXXX$ ls
appletviewer javadoc jmap native2ascii serialver
apt javah jps orbd servertool
extcheck javap jrunscript pack200 tnameserv
idlj javaws jsadebugd policytool unpack200
jar jconsole jstack rmic wsgen
jarsigner jdb jstat rmid wsimport
java jhat jstatd rmiregistry xjc
javac jinfo keytool schemagen
TigreDARK:bin XXXXX$ javaws
No Java runtime present, requesting install.
Unable to locate a Java Runtime to invoke.
TigreDARK:bin XXXXXXX$ ./javaws
Java Web Start splash screen process exiting .
Can not find message file: No such file or directory
TigreDARK:bin XXXXXXX$ ./javaws /Users/myuser/Desktop/login.jsp
TigreDARK:bin XXXXXXXX$ Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file /System/Library/Java/Support/Deploy.bundle/Contents/Home/lib/deploy.jar
TigreDARK:lib XXXXXX$ ls -l
drwxr-xr-x 5 root wheel 170 5 jun 19:30 deploy
lrwxr-xr-x 1 root wheel 31 18 jun 12:54 deploy.jar -> ../../Resources/Java/deploy.jar
lrwxr-xr-x 1 root wheel 31 18 jun 12:54 javaws.jar -> ../../Resources/Java/javaws.jar
lrwxr-xr-x 1 root wheel 31 18 jun 12:54 plugin.jar -> ../../Resources/Java/plugin.jar
drwxr-xr-x 6 root wheel 204 18 jun 12:54 security
-bash: java_home: command not found
TigreDARK:libexec xxxxxxx$ ls -la java_home
lrwxr-xr-x 1 root wheel 79 18 jun 12:54 java_home -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
TigreDARK:libexec xxxxxx$ ./java_home --verbose
Matching Java Virtual Machines (2):
1.6.0_33-b03-424, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_33-b03-424, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
I already lunch the disk utility to fix permissions problem on the files. from utility say it solve, but is not true.
When I click on the Unix executable file, a terminal window pops up with the following message:
I downloaded the latest Java version (15.0.2) and, as recommended in similar questions, added its path to the .config file, however, nothing works.
Thanks for the help!
It seems that your Java binary cannot be found. May I suggest adding to output of the following commands in a Terminal ? "java -version", "echo $JAVA_HOME" and "echo $JDKHOME"
Hey @FloT, I did as you suggested, but it still does not work. The output of java -version is: java version "16" 2021-03-16 Java(TM) SE Runtime Environment (build 16+36-2231) Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
Yes @amiro, I wasn't expecting this to make to stuff work, only to give some ideas of what goes wrong :-) does "echo $JAVA_HOME" shows a path ?
WritingSolutions2020 commented Mar 6, 2018
Actually I think this may be a PyDev extension problem. The popup shown in the original post doesn't occur until I open a PY file. (I'm working entirely with Python, not Java).
ANYHOW I've uninstalled Visual Studio Code and moved on. We can re-close this if you'd like.
TL; DR
WritingSolutions2020 commented Mar 6, 2018 •
A bit more information. The problem I'm having is that it appears the NONE of the extensions that require a JRE / SDK work. This despite the fact that I've (1) configured and tested JAVA_HOME and PATH, and (2) carerfully configured VCS's JSON configurations.
With regard to JRE / SDK, I have other programs -- Eclipse, jEdit, and others -- that require a JRE. They are all working properly after I installed and pointed them to jdk1.8.0_161. I've also used java -version in various places to ensure that that SDK is now this computer's default.
Also, VCS does not report the error until I (a) have PyDev installed, and (b) open a Python 3 source file. So the central problem appears to me to be that PyDev can't use the information I've carefully provided to enable it to find the SDK it needs. AND after removing the PyDev extension the "JRE not found" error no longer occurs.
akaroml commented Oct 26, 2017
@bsaby please verify if you can still reproduce the issue by setting JAVA_HOME properly.
Для JDK 11 попробуйте следующее:
Чтобы решить эту проблему чисто, я предлагаю использовать brew и jenv .
bsaby commented Oct 25, 2017
Yes. And after this error occured, restart vscode, Java runtime will work fine.
Подробности
На M1 Mac / Apple Silicon (работающем под управлением Big Sur) я уже openjdk установил. Как указано в предыдущем ответе Мохаммеда, openjdk используется только для бочки brew и, следовательно, требуется добавить символическую ссылку .
После этого он решил No Java Runtime present ошибку, но rJava пожаловался на отсутствие libjvm.dylib и существующие библиотеки для неправильной архитектуры:
Установка Eclipse Temurin (ранее AdoptOpenJDK ) (и удаление ранее созданной символической ссылки /Library/Java/JavaVirtualMachines/openjdk.jdk ) сразу же решила обе проблемы без проблем.
The text was updated successfully, but these errors were encountered:
akaroml commented Oct 27, 2017
@yaohaizh please further investigate this issue.
joygre1 commented Jun 6, 2019 •
Hello,
I just installed the Visual studio Code and for the life of me, I keep getting the Java run time could not be located and even after using the paths provided, the error remains. Can anyone kindly help this code newbie.
RobbiNespu commented Aug 26, 2020
sorry for bump the issue. seem this issue is appear on google 1st page, i share my quick solution. read my explanation below
Answers
(There was another download page, but it required an Oracle login.)
After installing, I then got the error (when building):
The top two suggestions at this SO didn't help (and when using the path mentioned farther below, the emulator wouldn't start and gave a Mac alert error). They both suggested the following:
This seems to work for most others. But a 1-vote answer (now 2) had a solution that worked for my situation. There were a few other answers that referenced this fix, but this answer was the clearest.
Double checking this solution, I opened Applications , right-clicked on Android Studio.app , selected Show Package Contents , then navigated to /Contents/jre , but there was no jdk .
So I just removed the /jdk from the path.
Although likely something I did, still no clue what might've changed from last week, and I'll just need to check/add this for each project.
I had a similar issue with react native but I think installing Java (JRE) is creating a new problem while partly fixing the original. For whatever reason your computer can't find your installed version of JDK. Either a path issue or another issue with the JDK install. This could potentially be fixed by simply updating your Java path in your terminals profile ( .profile, .bash_profile, .zshrc, etc ). i.e Make sure JAVA_HOME environment variable is set to the JDK’s folder. - if not reinstall JDK (instructions bellow)
When you install Java (JRE) and try build your app, the build now finds Javas JRE which has everything it is needs to run Java but not build it, this is why the new error is Could not find tools.jar. . The JDK includes the compiler (javac) and tools (like javadoc and jdb) and is what is needed to build your app. You then fixed the second error by forcing gradle (build tool) to look in the correct folder for your JDK.
I would recommend fixing this issue fully by first removing the Java you installed by running the following in your terminal:
And then reinstalling the JDK via brew by running: brew reinstall adoptopenjdk8
- Already download manually the Java from Apple site, reinstall 2 times and reboot. not solved.
MacBook Air, Mac OS X (10.6.8)
Posted on Jun 18, 2012 3:50 AM
Thanks to Brody and Mark Jalbert to help me to find the problem I hope this not ocurred again.
I give some feedback if this problem ocurred to other person, I see same error from 2009/2010. so is not a current problem, is a MacOS software problem of folders/permissions.
Now I reboot, and all is solved (I already reboot 3 times and check and uncheck box you say).
Now something change=
TigreDARK:~ Myuser$ /usr/libexec/PlistBuddy -c "Print" $HOME/Library/Preferences/ByHost/com.apple.java.JavaPreferences.*
Is not a good idea to add permissions to all folders, and give wrong permissions or more permissions o files. is really danger, please do a backup first if you want to do a test.
I think the permissions, and the reboot solve, but I'm not sure what really do this change.
how i fix the problem:
files i add permissions of my user, and write read:
I add here too a R+W permission to "system" and to my user r+w
I moved the ~/Library/Preferences/ByHost/com.apple.java.JavaPreferences.*.plist file and ran Java Preferences again.
4) Shutdown, and boot again.
IF PROBLEM PERSIST:=
Go to folder of JAVAWS path:
Lunch you jsp application:
TigreDARK:bin XXXXXXX$ ./javaws /Users/myuser/Desktop/login.jsp
If give you this error, like my error PROBLEM, is a permission of files problem.
TigreDARK:bin XXXXXXXX$ Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file /System/Library/Java/Support/Deploy.bundle/Contents/Home/lib/deploy.jar
Posted on Jun 18, 2012 9:31 AM
andxu commented Mar 6, 2018
Thanks for the feed back, close this issue.
yaohaizh commented Oct 25, 2017
It seems the value is not properly resolved by VSCode java extension at the first time. You need restart the VSCode after your set the system variable.
И добавьте это в конец своих сценариев конфигурации оболочки
~/.bashrc или ~/.zshrc
Затем перезапустите оболочку и попробуйте выполнить java -version
Примечание: Если у вас есть эта проблема, ваша текущая версия JDK не существует или неправильно сконфигурирована (или, возможно, у вас только JRE).
Смонтируйте файл образа диска и установите среду выполнения Java 6 для OS X.
- Невозможно найти JVM, соответствующую версии "(null)"
- Среда выполнения Java отсутствует, попробуйте --request для установки.
Это должно решить проблему со всплывающим окном, показанным ниже:
Но это супер старая Java. Установка его представляет собой угрозу безопасности, поскольку он больше не обновляется.
Ниже у меня работает версия macos mojave 10.14.6.
Тогда делай соответственно;
- vim .bash_profile
- добавить "экспорт JAVA_HOME = $ (/ usr / libexec / java_home)" в bash_profile
- источник .bash_profile
сделано. И вы можете проверить версию с помощью команды java -version.
У меня есть Mojave 10.14.6, и единственное, что у меня сработало, это:
- установка JAVA_HOME на следующее:
- источник .bash_profile (или где бы вы ни хранили свои вары, в моем случае .zshrc)
Надеюсь, это поможет! Теперь вы можете печатать, java --version и он должен работать
4 Answers 4
It seems that you are missing Java environment variable to make your program work.
What you can try:
Try to run caver_analyst with the --jdkhome switch, followed by (I guess) the path to a valid JDK as suggested in your error message. It should solve your problem.
Usually, the path to Java must be defined in a JAVA_HOME environment variable. Yours is obviously not defined, so let's define it manually :
- Open a Terminal
- Go to your home directory with command cd
- Look for a file called ".zshrc" in this directory:
- If it does not exist i.e. if the command ls .zshrc gives you a "No such file or directory" message, create the file: touch .zshrc
- Get the path to Java and keep it somewhere : which java
- Open the newly created file (it's a hidden file so you will have to show hidden files. Alternatively, you can edit the file in command line with nano .zshrc )
- At the end of the file, add the following line : export JAVA_HOME="/Path/to/your/java/home" and replace /Path/to/your/java/home with the path that you got at step 5.
- Save, close the file, reboot your laptop.
This file will be automatically read and its instructions executed when you open your profile. The "export" instruction creates an environment variable. You can verify if it was successfully created with echo $JAVA_HOME , echo being a command to display something. The "$" in front of the variable tells echo to look for a variable.
I hope this helps, but if it doesn't, please don't hesitate to share the error messages and step where it fails here.
Несмотря на то, что JRE 8 установлен на моей MAC OS Yosemite 10.10.3, при запуске Android, присутствующего в инструментах в sdk, в терминале отображается ошибка «Нет Java Runtime, запрос на установку» - как мне решить эту проблему?
Я хотел установить тестовый рекордер Xamarin - после установки они попросили меня установить Android sdk
SDK загружается в Library / Developer / Xamarin / android-sdk
Я установил JRE 8 и получил проверенную версию java со своего сайта.
Может кто-нибудь, пожалуйста, помогите !!
Вам необходимо установить полный JDK, а не только JRE.
У меня была такая же проблема, и я решил ее путем установки JDK.
Воспользуйтесь этой ссылкой, чтобы загрузить последнюю версию JDK 16.0.1.
Я получил эту ошибку при добавлении ключей SHA-1 сертификата подписи отладки в firebase, для Mac просто загрузите установщик Mac OS и установите его, как только закончите, и запустите команду генерации сертификата отладки, и она работает
В конце концов я решил эту проблему, разместив следующий экспорт JAVA_HOME в ~ / .bash_profile:
Надеюсь, это кому-то поможет. Я использую Mac OS High Sierra.
После установки openjdk с пивом и запуском brew info openjdk я получил это
И поэтому я получил эту команду здесь, и после ее запуска я получил Java, работающую
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Если вы столкнулись с ошибкой при попытке создать файл jks (хранилище ключей) , попробуйте добавить
перед запуском команды, вот так:
Поскольку похоже, что ваша переменная JAVA_HOME установлена неправильно, следуйте инструкциям по ее установке.
Я полагаю, как только вы установите это, он перестанет жаловаться.
Это правильный ответ - достаточно установить JRE и установить JAVA_HOME, чтобы команда Java стала доступной в оболочке.
andxu commented Mar 6, 2018 •
@WritingSolutions2020 please give more description of "And as others with this problem have noted, the solutions offered aren't working.", can you give us the a description about your problem:
- are you editing/debugging java code not python code?
- does the error pops show "Java runtime cannot be located"
- what the env variables of JAVA_HOME and PATH
- what's the result of bash/command prompt result of "which java" and "where java", eg:
yaohaizh commented Nov 6, 2017
WritingSolutions2020 commented Mar 5, 2018
For what it's worth, as of 05 March, 2018 the problem illustrated in the original poster's screenshot still exists.
For Linux Mint 32-bit. Visual Studio code 1.20.1.
Installed /java/jdk1.8.0_161 in /usr directory. In /bin used java -version to verify that the Java executable could be run without error.
Added path to JDK in both user and workspace settings:
User Settings:
Workspace Settings:
Although I'm creating Python 3.5 code and not Java code, installed the following extensions in response to guidance offered on this and other forums:
- Although I have resolved other issues (such as the inabiity of Visual Studio Code to find the system's instance of pylint, the JDK problem persists. And as others with this problem have noted, the solutions offered aren't working.
Для Java 11 сначала выполните следующие 2 шага:
bedge commented Oct 8, 2018
Seeing the same as @WritingSolutions2020 with:
VS Code version: Version 1.29.0-insider (1.29.0-insider)
OS and version: OSX High Sierra 10.13.6 (17G65)
Also, I'm using jenv which adds another layer of obfuscation, but all shells show:
bsaby commented Oct 26, 2017
Still reproduce this issue by setting JAVA_HOME properly using daily build 60.
And this issue only reproduce when reload not restart vscode after installing two java plugin
testforstephen commented Jun 10, 2019
@joygre1 The checking approach is provided by Language Support for Java(TM) by Red Hat extension, what version did you install Java language support extension?
On Jun 9, 2019, at 11:17 PM, Jinbo Wang ***@***.***> wrote: @joygre1 The checking approach is provided by Language Support for Java(TM) by Red Hat extension, what version did you install Java language support extension? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Читайте также: