Nativescript tns doctor tells me JDK is not configured correctly, even though it seems that it is.
I am currently running Big Sur on Mac.
After installing all the iOS and Android requirements I keep getting this error from TNS Doctor:
✖ Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements
✖ WARNING: The Java Development Kit (JDK) is not installed or is not configured properly.
In my ~/.bash_profile I have JAVA_HOME described as :
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
My entire ~/.bash_profile:
Setting PATH for Python 3.9
The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
printenv:
TERM_PROGRAM=Apple_Terminal
ANDROID_HOME=/usr/local/share/android-sdk
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/lb/d2r8qcsj3p765gs3pnhz9ndh0000gn/T/
TERM_PROGRAM_VERSION=440
ANDROID_SDK_ROOT=/usr/local/share/android-sdk
TERM_SESSION_ID=34C4C80E-4538-4E20-A8CD-F34C21412E64
USER=anthonydionise
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.QtbknDrCPH/Listeners
PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
__CFBundleIdentifier=com.apple.Terminal
PWD=/Users/anthony
JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
LANG=en_US.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/anthony
LOGNAME=anthony
_=/usr/bin/printenv
Aside from the tns errors, JAVA_HOME seems to be configured correctly; Running the avdmanager runs perfectly.
avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
Parsing /usr/local/Caskroom/android-sdk/4333796/build-tools/28.0.3/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/emulator/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/android/m2repository/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/google/m2repository/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/intel/Hardware_Accelerated_Execution_Manager/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/patcher/v4/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/platform-tools/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/platforms/android-28/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/system-images/android-25/google_apis/x86/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/tools/package.xmlAuto-selecting single ABI x86
Do you wish to create a custom hardware profile? [no] n
Seems to successfully create a device.
avdmanager list device
Parsing /usr/local/Caskroom/android-sdk/4333796/build-tools/28.0.3/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/emulator/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/android/m2repository/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/google/m2repository/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/extras/intel/Hardware_Accelerated_Execution_Manager/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/patcher/v4/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/platform-tools/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/platforms/android-28/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/system-images/android-25/google_apis/x86/package.xmlParsing /usr/local/Caskroom/android-sdk/4333796/tools/package.xmlAvailable Android Virtual Devices:
Name: test
Path: /Users/anthonydionise/.android/avd/test.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
The following Android Virtual Devices could not be loaded:
Name: Pixel_3a_API_30_x86
Path: /Users/anthonydionise/.android/avd/Pixel_3a_API_30_x86.avd
Error: Google pixel_3a no longer exists as a device
(Not quite sure what the pixel device is)
This setting in my .bash_profile file works for me:
export JAVA_HOME=$(/usr/libexec/java_home)
See this related question and answer here:
How to set JAVA_HOME environment variable on Mac OS X 10.9?
Related
I am using Homebrew to install Android dev tools
brew install gradle
brew install android-sdk
Then I am getting command not found when running avdmanager.
➜ ~ avdmanager
zsh: command not found: avdmanager
How to open the AVD manager on OSX from the command line?
Environment variables missing maybe?
Considering the SDK is installed under /Users/<your_user>/Library/Android/sdk folder which is the Android Studio preferred SDK location, but it works fine under /usr/local/share/android-sdk as well, which is a location pretty much used on CI mostly.
Add the following either on the .zshrc file. ( or .bash_profile on iTerm )
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
On the terminal
➜ ~ source .zshrc
It outputs
➜ ~ sdkmanager --version
26.1.1
See https://developer.android.com/studio/command-line/variables
I just installed Maven via Mac Catalina via command line and mvn -version was showing output. then it went away. Please help.
May be a long post, but in the end you will have a convenient tool to install packages and understanding of how to configure them.
Why maven "disappeared" I have no idea of, so what I would do in this situation:
First of all, I would delete maven manually (find the directory and remove it along with any other files that were setup during maven installation)
Then I would highly recommend using Homebrew - a package manager for macOS
To install Homebrew, open terminal and execute the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Wait for a couple of minutes (a less) until it is installed
Now, that Homebrew is installed, you have a very convenient tool to install stuff on your mac
So, you want to install Maven. You can find Maven on Homebrew
Now you just have to open your terminal again and execute
brew install maven
After a few seconds brew will display the directory it installed Maven in (by default, all Homebrew packages are installed in /usr/local/Cellar/)
You are almost there, now you need to set the environment variable.
As described by Apache, the environment variable needs to be added to the PATH environment variable.
Here I have some uncertainty in terms of what file to use: .bash_profile or zprofile. The confusion is caused by the fact that in latest macOS update (maybe several latest updates) Apple decided to use zsh shell, and so .bash_profile became somewhat functionally equivalent to zprofile. There are many articles on the Internet about what file to use, so you better check them out before proceeding (sorry for not providing links).
On my Catalina 10.15.6 I use .zprofile and everything looks to work perfectly.
Once you decide what file to use, execute the following in the terminal:
nano .zprofile
An editor will open, write this:
export PATH=/usr/local/Cellar/maven/*version*/bin:$PATH
Press Control + X to exit, then Y to save changes and hit Enter to exit the editor
After that you will again be in terminal, where execute:
source .zprofile
To load it. Then close the terminal, open again and check that PATH variable is edited by executing:
env
That's it! Good luck coding!
For MacOs Catalina, below is what worked for me.
Terminal > Vim .zprofile
Add:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
export JAVA_HOME
M2_HOME=/Users/username/apache-maven-3.8.1 (This is where my maven folder is.)
export M2_HOME
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH
Terminal > source ~/.bash_profile
Restart Terminal > mvn -version
Output:
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Users/username/apache-maven-3.8.1
Java version: 1.8.0_281, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
username#C02F ~ % java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
Did you try executing:
source ~/.zshrc
I know there are a lot of questions/answers about this question, but all were failed in my case.
I installed jdk 1.8 and then installed maven3.6.3, java runs well but mvn command didn't work, see my command output and env:
java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
mvn -v
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
mac OS version: 10.15.5
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
echo $PATH
/usr/local/apache-maven-3.6.3/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.
config in ~/.bash_profile
export M2_HOME=/usr/local/apache-maven-3.6.3
PATH=$M2_HOME/bin:$JAVA_HOME/bin:$PATH:.
#Mac OSX 10.15.5 or later version need this configure
export JAVA_HOME=$(/usr/libexec/java_home)
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH
I also source ~./bash_profile to make configure effective.
I would suggest revert all the changes you have made in ~/.bash_profile. Checkout my way to make the maven work:
Download latest maven zip package apache-maven-<version>-bin.zip from Apache maven download page.
Unzip it to any place, e.g: ~/Develop/apache-maven-3.6.0
Create a link with command sudo ln -sf ~/Develop/apache-maven-3.6.0/bin/mvn /usr/local/bin/mvn (change version number per your case, if the local bin folder missing, just create it mkdir -p /usr/local/bin).
Check the installation mvn --version
Hope it works for you.
After hundreds updating configure file, now mvn -version can works, share my update and hope it can help you.
fill or update vim ~/.mavenrc(in the beginning, this file isn't exist)
# my MacOS is 10.15+
export Java_HOME=$(/usr/libexec/Java_home)
and then source ~/.mavenrc to let system env effective.
Summary:for my mac system, seems maven couldn't get JAVA_HOME from .bash_profile or .profile, so if you confirm your JAVA_HOME is set correctly and MAVEN_HOME configured, then you can have a try in this way.
I am using WSL in Windows 10. I have this warning getting displayed when I run a python file:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-aadithyasb'
I can understand that the XDG_RUNTIME_DIR environment variable is not set and it is creating its own path /tmp/runtime-aadithyasb
I am getting this warning from the moment I installed Xserver for Windows using VcXsrv to open plots when the file is ran.
Wy question is should I add this XDG_RUNTIME_DIR environment variable in windows or is there any method to set a directory under the variable for Ubuntu used under WSL?
I was able to find what the caused the terminal to issue the warning. Yet I am posting this so that it would be useful for people someday who are new to using WSL like me. This link helped me to solve it and gave me a better insight on how linux works under a WSL:
https://dev.to/winebaths/getting-up-and-running-with-the-windows-subsystem-for-linux-8oc
To solve this issue I just added the below lines to my .bashrc file:
export XDG_RUNTIME_DIR=/some/directory/you/specify
export RUNLEVEL=3
After this just run the command
source .bashrc
Now the warning will not keep displaying in your terminal.
Last week, I had a similar error installing a Orange3's library
My environment is:
Ubuntu 18.04
python3 (3.6)
orange3 (3.27.1)
pyQt5 (5.15)
The trouble was:
When I tried to compile orange3 in a command line:
sudo python3 -m Orange.canvas
The system showed:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'/home/rene/.local/lib/python3.6/site-packages/orangewidget/widget.py:287: RuntimeWarning: subclassing of widget classes is deprecated and will be disabled in the future.Extract code from OWBaseVectorizer or explicitly open it.RuntimeWarning)
Fault segment
The trouble for this system error was:
Orange3 (3.27.1) is not compatible with PyQt5 (5.15).
However, PyQtWebEngine will be compatible with a PyQt5 upper version to 5.12
I searched in internet the different versions of rhis library and I installed a version between 5.12 and 5.15
Thus, I did I had a downgrade of the PyQt5's library to 5.13.1:
pip3 install PyQt5 == 5.13.1 --use-feature = 2020-resolver
As result of this:
Orange3 compile again
I had this problem too just today. What I did was that I opened up PowerShell and killed Ubuntu WSL with the following command:
wsl.exe --shutdown
After that, I opened VcXsrv with its shortcut called "XLaunch" and made sure to tick off "Disable access control".
I have installed jdk1.8.0_121 already and JAVA_HOME seems correct.
But when I open terminal, it always reminds me "Unable to find any JVMs matching version "1.8.0_40"".
jdk1.8.0_40 was installed Previously but I hava already uninstalled this version.
Does anyone know how to remove this annoying reminder?
Thanks a lot.
MacOS X does not come with Java Development Kits (JDKs) pre-installed.
Run java -version in the terminal and you may be prompted to install Java. Unless you already have JVM installed, in which case you will see the build version number.
Next, you will be prompted to visit the Java SE Development Kit Downloads page. Download one of the JDK (Java Development Kits) with a file extension ending in <filename>.tar.gz.
Then run tar -xf <filename>.tar.gz.
Rename the newly created directory to JAVA_HOME.
i solved this using this command in terminal
brew install --cask homebrew/cask-versions/adoptopenjdk8
#sideshowbarker, you're right. I checked all shell initialization files and found the java version was set as 1.8.0_40 in /etc/profile.
Thanks again.
please use like brew cask install adoptopenjdk8 to install deprecated java version, esp. for Android Studio.
use java_home -V to show all install version of java, like:
/usr/libexec/java_home -V
Matching Java Virtual Machines (5):
12.0.2, x86_64: "Java SE 12.0.2" /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
12.0.1, x86_64: "OpenJDK 12.0.1" /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home
1.8.0_222, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
and within .zshrc or .bash_profile for setting default jdk, like use command setjdk 1.8
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
function setjdk() {
export JAVA_HOME=`/usr/libexec/java_home -v $#`
}
and with recent java/jdk v12, the Android Studio CLI not work:
$setjdk 12
$avdmanager
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
I have faced the JVM issue while installing flutter, so my finding is particularly based on macOS 10.15.5, if you install the latest java the JVM error will still show up. For that, you have to install legacy version of java from apple.
Download the java from here
https://support.apple.com/kb/DL1572?locale=en_GB
then
Launchpad -> Other -> Script Editor
create a new document and paste the below code as it is
set theDMG to choose file with prompt "Please select javaforosx.dmg:" of type {"dmg"}
do shell script "hdiutil mount " & quoted form of POSIX path of theDMG
do shell script "pkgutil --expand /Volumes/Java\ for\ macOS\ 2017-001/JavaForOSX.pkg ~/tmp"
do shell script "hdiutil unmount /Volumes/Java\ for\ macOS\ 2017-001/"
do shell script "sed -i '' 's/return false/return true/g' ~/tmp/Distribution"
do shell script "pkgutil --flatten ~/tmp ~/Desktop/ModifiedJava6Install.pkg"
do shell script "rm -rf ~/tmp"
display dialog "Modified ModifiedJava6Install.pkg saved on desktop" buttons {"Ok"}
then Script -> Compile and then Script -> Run.
a popup will ask you to locate your downloaded file javaforosx.pkg
Running the script will create a ModifiedJava6Install.pkg on your desktop.
Run this ModifiedJava6Install.pkg to install the legacy Java version.