JAVAC problem while setting up NativScript on Ubuntu 16.04


#1

Hi everyone,
I have been trying to set up NativeScript on my Ubuntu 16.04 computer but despite the fact that I follow all the steps in the guide:
http://docs.nativescript.org/start/ns-setup-linux
When I run the command:
tns doctor
an error appears:

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.

I run the tns doctor --log trace and all this text appears:

Loading extensions.
Exec uname -a 
 stdout: Linux carles-ThinkPad-S5-Yoga-15 4.8.0-56-generic #61~16.04.1-Ubuntu SMP Wed Jun 14 11:58:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
 
 stderr: 
Exec npm -v 
 stdout: 3.10.10
 
 stderr: 
spawn: java "-version"
Exec node-gyp -v 
 stdout:  
 stderr: /bin/sh: 1: node-gyp: not found

Exec null version 
 stdout:  
 stderr: /bin/sh: 1: null: not found

spawn: emulator "-help"
The result of checking is Android Emulator installed is:
- stdout: 
- stderr: spawn emulator ENOENT
Exec mono --version 
 stdout:  
 stderr: /bin/sh: 1: mono: not found

Exec git --version 
 stdout:  
 stderr: /bin/sh: 1: git: not found

Exec gradle -v 
 stdout:  
 stderr: /bin/sh: 1: gradle: not found

Exec "javac" -version 
 stdout:  
 stderr: javac 1.8.0_121

System information:
{ procInfo: 'nativescript/3.0.3',
  platform: 'linux',
  os: 'Linux carles-ThinkPad-S5-Yoga-15 4.8.0-56-generic #61~16.04.1-Ubuntu SMP Wed Jun 14 11:58:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux\n',
  shell: '/bin/bash',
  dotNetVer: null,
  procArch: 'x64',
  nodeVer: 'v6.11.0',
  npmVer: '3.10.10',
  javaVer: '1.8.0',
  nodeGypVer: null,
  xcodeVer: null,
  xcodeprojGemLocation: null,
  itunesInstalled: false,
  cocoapodVer: null,
  adbVer: null,
  emulatorInstalled: false,
  monoVer: null,
  gitVer: null,
  gradleVer: null,
  javacVersion: '1.8.0_121' }
Looking for project in '/home/carles'
Looking for project in '/home'
Looking for project in '/'
No project found at or above '/home/carles'.
Unable to find project. projectDir: null, options.path: undefined, /home/carles
No project found at or above '%s' and neither was a --path specified.
Initializing analytics statuses.
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track feature 'CLI' with value 'doctor'.
WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.join (path.js:1211:7)
    at AndroidToolsInfo.getInstalledTargets (/usr/lib/node_modules/nativescript/lib/android-tools-info.js:266:45)
    at AndroidToolsInfo.descriptor.(anonymous function) (/usr/lib/node_modules/nativescript/lib/common/decorators.js:19:40)
    at AndroidToolsInfo.getLatestValidAndroidTarget (/usr/lib/node_modules/nativescript/lib/android-tools-info.js:258:37)
    at AndroidToolsInfo.getCompileSdkVersion (/usr/lib/node_modules/nativescript/lib/android-tools-info.js:188:53)
    at AndroidToolsInfo.getToolsInfo (/usr/lib/node_modules/nativescript/lib/android-tools-info.js:37:47)
    at AndroidToolsInfo.descriptor.(anonymous function) (/usr/lib/node_modules/nativescript/lib/common/decorators.js:19:40)
    at AndroidToolsInfo.validateInfo (/usr/lib/node_modules/nativescript/lib/android-tools-info.js:49:34)
    at DoctorService.<anonymous> (/usr/lib/node_modules/nativescript/lib/services/doctor-service.js:96:61)
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track feature 'CLI' with value 'help'.
List of registered commands: /?, appstore, appstore|upload, autocomplete, autocomplete|disable, autocomplete|enable, autocomplete|status, build, build|android, build|ios, clean-app, clean-app|android, clean-app|ios, create, debug, debug|android, debug|ios, deploy, dev-generate-help, dev-generate-messages, dev-post-install, dev-preuninstall, dev-test, dev-test|android, dev-test|ios, device, devices, devices|android, devices|ios, device|android, device|get-file, device|ios, device|list-applications, device|list-files, device|log, device|put-file, device|run, device|stop, device|uninstall, doctor, emulate, emulate|android, emulate|ios, error-reporting, extension, extension|install, extension|uninstall, help, info, init, install, platform, platform|add, platform|clean, platform|remove, platform|update, plugin, plugin|add, plugin|install, plugin|remove, plugin|update, post-install-cli, prepare, proxy, proxy|clear, proxy|set, publish, publish|ios, run, run|android, run|ios, test, test|android, test|init, test|ios, update, usage-reporting
Reading help for command 'doctor'. FileName is 'doctor.md'.
# doctor

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Usage   β”‚ Synopsis     β”‚
β”‚ General β”‚ $ tns doctor β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.

Has anyone know how to solve this?
Thank you very much


#2

I believe the Ubuntu OS comes with a distribution of the Open JDK project, while you need the Oracle’s.

Try setting a system alternative - https://askubuntu.com/a/272190

That helped my case when I was setting up a Fedora machine.


#3

Hi Pete,
Thank for the reply but I’ve already test all the possible configurations of the alternatives (for java and javac). So I don’t know why it’s already happening.
Another solution?