Nativescript-cli: Installation problem with JAVA_HOME environment variable

Created on 28 Jun 2017  路  6Comments  路  Source: NativeScript/nativescript-cli

I have installed nativescript using the windows installer, but have a problem with JAVA_HOME.

It is installed:
C:\Users\Narelle>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)

  C:\Users\Narelle>echo %JAVA_HOME%
  "C:\Program Files (x86)\Java\jdk1.8.0_131"

But tns doctor does not find it:

  ## C:\Users\Narelle>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 Devel
  ment Kit (JDK) and configured it according to system requirements as
  described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.htm
  system-requirements

How can I find the error?

question windows

Most helpful comment

I found the problem. Windows environment variables can be a max length of 2064 characters.
Mine was too long, so I deleted duplicate paths, booted the machine, and it now finds the JAVA_HOME variable correctly.
Thanks dtopuzov for your help.

All 6 comments

Can you run dir "%JAVA_HOME%\bin\javac.exe" /B and make sure output is javac.exe?

If output is javac.exe -> Java is installed properly and may be you need to restart terminal where you run tns doctor or your %JAVA_HOME% is set as variable for some other user (not the one who run doctor).

If you get File Not Found then your Java installation is not ok.

This command tells me that my installation is not OK.
I uninstalled and reinstalled the Java JDK V1.8.0_131, but have the same problem.
The file javac.exe is in the directory C:\Program Files\Java\jdk1.8.0_131\bin. Full permissions are granted for admin, and read/execute for user.
JAVA_HOME has changed from C:\Program Files (x86) to C:\Program Files.
Environment variables are correct. PC has been restarted to ensure variables are up to date.
tns doctor does not find javac

I do not understand this at all!

Hi @nirvine

This command tells me that my installation is not OK.
What do you mean - tns doctor says Java is not OK, or dir "%JAVA_HOME%\bin\javac.exe" /B says Java is not OK?

May be you try to install x64 Java on x86 machine?
Please make sure java package you install is correct for your system.

By "not OK" I mean that I get "FILE NOT FOUND" when I run the dir command, as suggested at your first reply.
I have an x64 machine, and have installed the Java JDK version for 64 bit architecture.
the file from the Oracle download site is jdk-8u131-windows-x64.exe

Thanks for ongoing help!

What about dir "%JAVA_HOME%"?
Is it possible that environment variable is set for another user of this machine?
Can you set it as system variable (not user profile variable)?

I found the problem. Windows environment variables can be a max length of 2064 characters.
Mine was too long, so I deleted duplicate paths, booted the machine, and it now finds the JAVA_HOME variable correctly.
Thanks dtopuzov for your help.

Was this page helpful?
0 / 5 - 0 ratings