javacocos2d-xcocos2d-js

Issue with compiling a cocos2d-x 3.17.2 JS/web project


Cross-posting from https://discuss.cocos2d-x.org/t/issue-with-compiling-a-project/57198

I am having an issue trying to compile a new cocos2dx JS project.

I have a fresh Ubuntu 18.04 box setup with Java 1.8, Cmake, and all other dependencies as mentioned @ https://docs.cocos.com/cocos2d-x/manual/en/installation/Linux.html

Now when I create and run new projects with

cocos new -l js test
cd test
cocos run -p web

It works flawlessly.

But when I try to compile with cocos compile -p web -m release I am getting

Building mode: release
No valid JDK found

I tried adding

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH=$JAVA_HOME:$PATH

and then

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre"
export PATH=$JAVA_HOME:$PATH

and then

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"
export PATH=$JAVA_HOME:$PATH

With each of above settings, sourced .bashrc and tried running cocos compile -p web -m release only to get

Building mode: release
No valid JDK found

Any hint on what am I doing wrong? Highly appreciate any responses.

Thanks.


Solution

  • Got this working with Java 1.7 and Apache ant 1.9

    As defined in /tools/cocos2d-console/plugins/plugin_compile/build_web/init.py, cocos2dx 3.17.2 works only with Java 1.6 or 1.7