nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

[OpenJDK] tns platform add android: Error executing command 'javac'.

Open daxim opened this issue 10 years ago • 38 comments

Following the tutorial, step 1-3:

~/hack/nativescript/sample-Groceries$ tns platform add android
Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
~/hack/nativescript/sample-Groceries$ echo $JAVA_HOME
/usr/lib64/jvm/java
~/hack/nativescript/sample-Groceries$ javac
Usage: javac <options> <source files>
where possible options include:
  @<filename>                  Read options and filenames from file
  -Akey[=value]                Options to pass to annotation processors
  --add-modules <module>(,<module>)*
        Root modules to resolve in addition to the initial modules, or all modules
        on the module path if <module> is ALL-MODULE-PATH.
  --boot-class-path <path>, -bootclasspath <path>
        Override location of bootstrap class files
  --class-path <path>, -classpath <path>, -cp <path>
        Specify where to find user class files and annotation processors
  -d <directory>               Specify where to place generated class files
  -deprecation
        Output source locations where deprecated APIs are used
  -encoding <encoding>         Specify character encoding used by source files
  -endorseddirs <dirs>         Override location of endorsed standards path
  -extdirs <dirs>              Override location of installed extensions
  -g                           Generate all debugging info
  -g:{[lines, vars, source],[lines, vars, source],[lines, vars, source]}
        Generate only some debugging info
  -g:none                      Generate no debugging info
  -h <directory>
        Specify where to place generated native header files
  --help, -help                Print a synopsis of standard options
  -implicit:{[none, class],[none, class]}
        Specify whether or not to generate class files for implicitly referenced files
  -J<flag>                     Pass <flag> directly to the runtime system
  --limit-modules <module>(,<module>)*
        Limit the universe of observable modules
  --module <module-name>, -m <module-name>
        Compile only the specified module, check timestamps
  --module-path <path>, -p <path>
        Specify where to find application modules
  --module-source-path <module-source-path>
        Specify where to find input source files for multiple modules
  -nowarn                      Generate no warnings
  -parameters
        Generate metadata for reflection on method parameters
  -proc:{[none, only],[none, only]}
        Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]
        Names of the annotation processors to run; bypasses default discovery process
  --processor-module-path <path>
        Specify a module path where to find annotation processors
  --processor-path <path>, -processorpath <path>
        Specify where to find annotation processors
  -profile <profile>
        Check that API used is available in the specified profile
  --release <release>
        Compile for a specific VM version. Supported targets: 6, 7, 8, 9
  -s <directory>               Specify where to place generated source files
  -source <release>
        Provide source compatibility with specified release
  --source-path <path>, -sourcepath <path>
        Specify where to find input source files
  --system <jdk>|none          Override location of system modules
  -target <release>            Generate class files for specific VM version
  --upgrade-module-path <path>
        Override location of upgradeable modules
  -verbose                     Output messages about what the compiler is doing
  -version                     Version information
  -Werror                      Terminate compilation if warnings occur
  -X                           Print a synopsis of nonstandard options

The message from the tns platform command is useless because it does not say what the error is.

daxim avatar Nov 27 '16 08:11 daxim

Have you exported the $JAVA_HOME? It must be visible to the child process.

PanayotCankov avatar Dec 08 '16 08:12 PanayotCankov

The variable is already set at an earlier time. Of course it will be part of the environment of child processes spawned from the shell:

$ echo $JAVA_HOME
/usr/lib64/jvm/java
$ perl -E'say $ENV{JAVA_HOME}'
/usr/lib64/jvm/java
$ node -p process.env.JAVA_HOME
/usr/lib64/jvm/java

Why is this tagged as question? I am not asking a question, I am reporting a bug. Why do you close the ticket before it's resolved? Kindly reopen.

daxim avatar Dec 08 '16 18:12 daxim

↑ @PanayotCankov ↑

daxim avatar Dec 12 '16 19:12 daxim

Having the same issue here. Everything is configured as it should be, but I keep getting the error, no matter which tns command I try.

kristoftorfs avatar Dec 13 '16 20:12 kristoftorfs

@daxim My problem when away after setting the OpenJDK v8.

sudo update-alternatives --config java
sudo update-alternatives --config javac

kristoftorfs avatar Dec 13 '16 20:12 kristoftorfs

I have the same problem. Any solution?

alextfos avatar Mar 29 '17 16:03 alextfos

Hey guys, sorry for the late reaction. Do you still have this issue? @alextfos @kristoftorfs @daxim

pkoleva avatar Jun 12 '17 08:06 pkoleva

@cdarken ☝️

petekanev avatar Jun 12 '17 08:06 petekanev

is this safe to ignore? since android studio works fine for me despite this warning. message what that error was when executing javac would be nice

aep avatar Jun 30 '17 17:06 aep

Hi @aep

Can you elaborate a bit more on is this safe to ignore? Do you see some errors now, what are the steps to reproduce them?

dtopuzov avatar Jul 31 '17 12:07 dtopuzov

Closing due to inactivity.

dtopuzov avatar Aug 18 '17 06:08 dtopuzov

yep, still getting the message, but everything works fine.

$ javac -version 
javac 1.8.0_141

aep avatar Aug 18 '17 10:08 aep

Hi @aep

Is your java OpenJDK or it is Oracle's JDK?

Did you try this solution?

dtopuzov avatar Aug 18 '17 12:08 dtopuzov

@dtopuzov openjdk. i dont use ubuntu. so no. also i cant really reproduce this anymore, after a system update, sorry. maybe it's already fixed in the meantime?

aep avatar Aug 18 '17 12:08 aep

Thanks, for the info, it looks like we have this issue only with OpenJDK (we recommend Oracle's JDK).

dtopuzov avatar Aug 18 '17 12:08 dtopuzov

I'm having the same problem. I'm using Oracle's JDK, JAVA_HOME is in the PATH, android studios works OK and also the emulator.

But tns run android do not work, it say:

"Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable."

Please, fix this

pablo-novoa avatar Sep 10 '17 05:09 pablo-novoa

I have the same problem I use javac in my terminal fine but the script say "Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable." when "Verifying CocoaPods. This may take some time, please be patient.."

cristoferfb avatar Sep 23 '17 22:09 cristoferfb

+1

Spatlani avatar Sep 25 '17 19:09 Spatlani

same issue here on a mac

mnovak20 avatar Sep 27 '17 16:09 mnovak20

ok I've been dealing with this since yesterday and the issue finally went away.

I had jdk-9 and jdk-8 so I removed both using the commands in this stackoverflow thread https://stackoverflow.com/questions/19039752/removing-java-8-jdk-from-mac

Then reinstalled jdk-8u144-macosx-x64.dmg after restarting. Once that was done, I ran tns doctor but it complained about android sdks so I added the ANDROID_HOME variable path again. After that, I ran tns doctor one more time and the javac error went away.

Hopefully this helps someone.

mnovak20 avatar Sep 27 '17 17:09 mnovak20