12

I am trying to emulate an app on my device with cordova in OpenSuse Leap 42.1.
But when I tried to emulate the app with the cordova run I get the error below:

cordova run
Running command: /home/soufraz/Projects/apps/myproject/platforms/android/cordova/run 
ERROR: Error: Failed to run "java -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0

ERROR running one or more of the platforms: Error: /home/soufraz/Projects/apps/myproject/platforms/android/cordova/run: Command failed with exit code 2
You may not have the required environment or OS to run this project

I have the java installed and the paths set in ~/.profile.
Which is the configuration error in my environment?

Below my .profile:

JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0
export JAVA_HOME

ANDROID_HOME=/home/soufraz/Install/android-sdk-linux
export ANDROID_HOME

PATH=$PATH:$ANDROID_HOME:$JAVA_HOME

Info about java version:

java -version
openjdk version "1.8.0_60"
OpenJDK Runtime Environment (build 1.8.0_60-b27)
OpenJDK 64-Bit Server VM (build 25.60-b23, mixed mode)

And here the list of jvm folder:

ls -l
total 28
lrwxrwxrwx 1 root root 24 Nov 12 11:28 java-1.7.0-openjdk -> java-1.7.0-openjdk-1.7.0
drwxr-xr-x 1 root root  6 Nov 12 11:28 java-1.7.0-openjdk-1.7.0
drwxr-xr-x 1 root root  6 Nov 11 17:26 java-1.8.0-openjdk-1.8.0
lrwxrwxrwx 1 root root 21 Nov 11 17:26 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 Nov 12 11:28 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
lrwxrwxrwx 1 root root 28 Nov 12 11:28 jre-1.7.0-openjdk -> java-1.7.0-openjdk-1.7.0/jre
lrwxrwxrwx 1 root root 27 Nov 11 17:26 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 28 Nov 11 17:26 jre-1.8.0-openjdk -> java-1.8.0-openjdk-1.8.0/jre
lrwxrwxrwx 1 root root 29 Nov 11 17:26 jre-openjdk -> /etc/alternatives/jre_openjdk

[edit] View tree with three levels:

tree -L 3
.
├── java-1.7.0-openjdk -> java-1.7.0-openjdk-1.7.0
├── java-1.7.0-openjdk-1.7.0
│   └── jre
│       ├── bin
│       └── lib
├── java-1.8.0-openjdk-1.8.0
│   └── jre
│       ├── bin
│       └── lib
├── jre -> /etc/alternatives/jre
├── jre-1.7.0 -> /etc/alternatives/jre_1.7.0
├── jre-1.7.0-openjdk -> java-1.7.0-openjdk-1.7.0/jre
├── jre-1.8.0 -> /etc/alternatives/jre_1.8.0
├── jre-1.8.0-openjdk -> java-1.8.0-openjdk-1.8.0/jre
└── jre-openjdk -> /etc/alternatives/jre_openjdk
Rafael Soufraz
  • 974
  • 3
  • 11
  • 28

5 Answers5

10

Cordova needs a JDK not a JRE, since it is checking for javac. See check_reqs.js line 86. From your comments you are saying that "Inside this path, there isn't the bin folder" in a JDK you should have a bin directory!

dan
  • 13,132
  • 3
  • 38
  • 49
  • I updated the question with a tree of `/usr/lib64/jvm`. Really there isn't a bin folder. And the name of main folder is `java-1.8.0-openjdk-1.8.0`. JDK. I need to install anything else? – Rafael Soufraz Nov 29 '15 at 12:04
7

In my specific case, I remove and reinstall all java packages and add one (for 'instinct'):
I removed:
java-1_8_0-openjdk
java-1_8_0-openjdk-headless
java-1_8_0-openjdk-plugin

And added:
java-1_8_0-openjdk
java-1_8_0-openjdk-headless
java-1_8_0-openjdk-plugin
java-1_8_0-openjdk-devel <<-- luckily I hit it

The bin inside main folder appears. With javac and another things.
Thank you guys!

Rafael Soufraz
  • 974
  • 3
  • 11
  • 28
6

Your path should be like this

PATH=$PATH:$ANDROID_HOME/bin:$JAVA_HOME/bin

and than export PATH

laalto
  • 150,114
  • 66
  • 286
  • 303
Bilal Shah
  • 1,135
  • 7
  • 17
  • 42
  • @RafaelSoufraz yes. you are pointing `PATH` to `$JAVA_HOME/jre/bin` however it should be pointed to `$JAVA_HOME/bin` – Bilal Shah Nov 29 '15 at 11:54
  • Did you red my first comment? "Inside this path, there isn't the bin folder." – Rafael Soufraz Nov 29 '15 at 11:58
  • I know that you're trying to help me. But I alredy tried this steps. Thank you. – Rafael Soufraz Nov 29 '15 at 11:59
  • Can you please do `JAVA_HOME=/usr/lib/jvm/default-java` this. The reason is that your executable is in `/usr/bin` folder that is why there is no `bin` folder in that. Also follow this http://stackoverflow.com/questions/663658/what-is-the-correct-target-for-the-java-home-envrionment-variable-for-a-linux-op it may help you. – Bilal Shah Nov 29 '15 at 13:52
5

It's a bit of misunderstanding with java-X_X_X-openjdk packages. Especially when you are used to default Oracle notation.

The JDK part is confusing, because OpenJDK is a project of an open-source implementation of the Java Platform and not a JDK - package actually allowing you to develop in Java. (more precise info here: http://openjdk.java.net/install/index.html)

TLDR:

  1. java-X_X_X-openjdk is Oracle's JRE equivalent.

  2. java-X_X_X-openjdk-devel is Oracle's JDK equivalent.

Mateusz Was
  • 193
  • 10
0

Verifying java & JDK installations resolved my problem.. Install java & JDK and try..

To build and run apps, you need to install SDKs for each platform you wish to target. Alternatively, if you are using browser for development you can use browser platform which does not require any platform SDKs.

To check if you satisfy requirements for building the platform:

$ cordova requirements
Requirements check results for android:
Java JDK: installed .
Android SDK: installed
Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:23
Gradle: installed

Requirements check results for ios:
Apple OS X: not installed
Cordova tooling for iOS requires Apple OS X
Error: Some of requirements check failed
BEJGAM SHIVA PRASAD
  • 2,181
  • 1
  • 18
  • 27