You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2021/04/18 10:50:00 UTC

[GitHub] [cordova] raphinesse edited a comment on issue #284: Can We Work with Multiple JDK Version?

raphinesse edited a comment on issue #284:
URL: https://github.com/apache/cordova/issues/284#issuecomment-821971872


   I think it's safe to say that everyone in the Cordova team would be happy if we could stop having to require JDK 8. We always have inherited this requirement from the Android tooling. While it seems that it might finally be possible to use a newer JDK with Android tooling, there's a lot to watch out for with your setup and there would still be changes to be made to cordova-android. We probably will get there eventually, but it is just not a top priority right now.
   
   I do not think we want to introduce a command line option to set the JDK. There is a simple workaround: setting `JAVA_HOME` and `PATH` environment variables. In POSIX shells (e.g. Git Bash) this could look like this:
   
   ```
   export JAVA_HOME=C:/oldJava/jdk8
   export PATH=$JAVA_HOME/bin:$PATH
   ```
   
   In Windows `cmd` (untested):
   ```
   set JAVA_HOME=C:/oldJava/jdk8
   set PATH=%JAVA_HOME%/bin;%PATH%
   ```
   
   After that, all commands in this shell session will use the updated environment variables. So you can just use `cordova run android`. You can also change environment variables per command. The complexity of that varies depending on your shell.
   
   On Unix-like operating system (macOS, Linux, …) you can nicely automate this process using [direnv](https://direnv.net/). I just put above commands inside a `.envrc` file in the projects that use `cordova-android` and `direnv` applies the changes to the environment variables whenever I change into that directory.
   
   Of course you can also write a little helper script named `usejdk8` that changes the environment.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org