I cannot seem to use Gradle with OpenJDK 1.9.
When I run the following command:
react-native run-android
I end up getting this error.
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9-internal'.
Running java -version shows me:
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
Any ideas how I can fix this?
Which version of gradle are you using?
cd android
./gradlew -version
I think there was a bug determining versions for java 1.9 which was fixed in Gradle 2.10.
Another option is to try spoofing a java.version that Gradle can parse
export JAVA_TOOL_OPTIONS='-Djava.version=1.9'
react-native run-android
#see JavaVersion.java and JavaVersionSpec.groovy
This seems to be an incompatibility with your build of OpenJDK 9 and Gradle.
Your OpenJDK version is:
openjdk version "9-internal"
And it appears Gradle can't parse it:
Could not determine java version from '9-internal'.
Looks like gradle is prepared to accept 9-ea, but not 9-internal.
You will have to modify your build of OpenJDK to have it return "9-ea" or something similar for java -version.
The following configure options when building OpenJDK 9 should do the trick:
configure \
--with-version-pre="ea" \
--with-version-opt="" \
... your other options ...
I had the same exact issue and, in my case, it worked by removing OpenJDK:
sudo rm /var/lib/dpkg/info/openjdk-*
sudo apt-get purge openjdk-*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update
and installing the Oracle Java SDK:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
I know this is not the exact answer (using Gradle with OpenJDK 1.9), but I managed to keep going and run the app both in a virtual device and in my smartphone. Hope it helps.
Note: I am running react-native: 0.40.0 and react-native-cli: 2.0.1 in Ubuntu 16.04
Related
I try to create docker image:
It is my Dockerfile:
FROM maven:3-jdk-11
# Common files and utils for build
RUN apt-get update && apt-get install -y make fakeroot rpm dpkg-dev apt-utils wget unzip
RUN apt-get install -y -q software-properties-common desktop-file-utils
# Then Wine with all deps
RUN dpkg --add-architecture i386 && apt-get update
RUN apt-get install -y --install-recommends wine
RUN apt-cache search openjdk
RUN apt-get install -y openjdk-11-jdk
RUN apt install -y openjfx11 libopenjfx-java libopenjfx-jni
RUN apt-get install -y --install-recommends wine32
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV JAVAFX_HOME /usr/share/java/openjfx11
# And we ready to play with our code
ARG SRCDIR=.
ARG DSTDIR=/usr/src/CryptoStock
ARG CACHEDIR=./cache
# Subject to be used here but should be command line, sic!
# ADD ${CACHEDIR} /root/.m2
# ADD ${SRCDIR} /mnt/src
RUN mkdir -p /root/.m2/repository
COPY settings.xml /root/.m2/settings.xml
COPY settings-security.xml /root/.m2/settings-security.xml
COPY jdk11-build-in-docker.sh ${DSTDIR}/jdk11-build-in-docker.sh
COPY ./static/. ${DSTDIR}/static
COPY ./3rdparty/. ${DSTDIR}/3rdparty
COPY ./winjdk11/. ${DSTDIR}/winjdk
ENV SOURCES /usr/src/CryptoStock
ENV OUTSIDE /mnt/src
RUN dpkg -l '*openjfx*'
RUN dpkg -l '*jdk*'
WORKDIR ${DSTDIR}
CMD [ "sh", "/usr/src/CryptoStock/jdk11-build-in-docker.sh" ]
When I try to build I don't to watch java 11:
Step 6/27 : RUN apt-cache search openjdk
---> Running in e03b4c69fa69
jtreg - Regression Test Harness for the OpenJDK platform
openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-8-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source - OpenJDK Development Kit (JDK) source files
openjdk-8-jre-dcevm - Alternative VM for OpenJDK 8 with enhanced class redefinition
uwsgi-plugin-jvm-openjdk-8 - Java plugin for uWSGI (OpenJDK 8)
uwsgi-plugin-jwsgi-openjdk-8 - JWSGI plugin for uWSGI (OpenJDK 8)
uwsgi-plugin-ring-openjdk-8 - Closure/Ring plugin for uWSGI (OpenJDK 8)
uwsgi-plugin-servlet-openjdk-8 - JWSGI plugin for uWSGI (OpenJDK 8)
Removing intermediate container e03b4c69fa69
---> 1fae3b35c58b
Step 7/27 : RUN apt-get install -y openjdk-11-jdk
---> Running in 288fb5247ce6
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package openjdk-11-jdk
The command '/bin/sh -c apt-get install -y openjdk-11-jdk' returned a non-zero code: 100
There is only java 8, there is no java 11.
OpenJDK 11 is installed by default in the maven:3-jdk-11 image:
$ docker run maven:3-jdk-11 java --version
openjdk 11.0.16 2022-07-19
OpenJDK Runtime Environment 18.9 (build 11.0.16+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.16+8, mixed mode, sharing)
It is also available via the Debian package system:
$ docker run maven:3-jdk-11 sh -c 'apt update && apt-cache search openjdk-11'
[...]
openjdk-11-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-11-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-11-doc - OpenJDK Development Kit (JDK) documentation
openjdk-11-jdk - OpenJDK Development Kit (JDK)
openjdk-11-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-11-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-11-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-11-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-11-source - OpenJDK Development Kit (JDK) source files
[...]
Today the maven:3-jdk-11 image is using Debian 11 (Bullseye), but when you wrote your question the maven:3-jdk-11 image was probably using a Debian 9 (Stretch) image with OpenJDK 11 installed but not available through the Debian package system. This explains your error.
How do I install/upgrade gradle for Mac?
As mentioned in this tutorial, it's as simple as:
To install
brew install gradle
To upgrade
brew upgrade gradle
(using Homebrew of course)
Also see (finally) updated docs.
Another alternative is to use sdkman. An advantage of sdkman over brew is that many versions of gradle are supported. (brew only supports the latest version and 2.14.) To install sdkman execute:
curl -s "https://get.sdkman.io" | bash
Then follow the instructions. Go here for more installation information. Once sdkman is installed use the command:
sdk install gradle
Or to install a specific version:
sdk install gradle 2.2
Or use to use a specific installed version:
sdk use gradle 2.2
To see which versions are installed and available:
sdk list gradle
For more information go here.
And using ports:
port install gradle
Ports , tested on El Capitan
I had downloaded it from http://gradle.org/gradle-download/. I use Homebrew, but I missed installing gradle using it.
To save some MBs by downloading it over again using Homebrew, I symlinked the gradle binary from the downloaded (and extracted) zip archive in the /usr/local/bin/. This is the same place where Homebrew symlinks all other binaries.
cd /usr/local/bin/
ln -s ~/Downloads/gradle-2.12/bin/gradle
Now check whether it works or not:
gradle -v
Two Method
using homebrew auto install:
Steps:
brew install gradle
Pros and cons
Pros: easy
Cons: (probably) not latest version
manually install (for latest version):
Pros and cons
Pros: use your expected any (or latest) version
Cons: need self to do it
Steps
download latest version binary (gradle-6.0.1) from Gradle | Releases
unzip it (gradle-6.0.1-all.zip) and added gradle path into environment variable PATH
normally is edit and add following config into your startup script( ~/.bashrc or ~/.zshrc etc.):
export GRADLE_HOME=/path_to_your_gradle/gradle-6.0.1
export PATH=$GRADLE_HOME/bin:$PATH
some other basic note
Q: How to make PATH take effect immediately?
A: use source:
source ~/.bashrc
it will make/execute your .bashrc, so make PATH become your expected latest values, which include your added gradle path.
Q: How to check PATH is really take effect/working now?
A: use echo to see your added path in indeed in your PATH
➜ ~ echo $PATH
xxx:/Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin:xxx
you can see we added /Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin into your PATH
Q: How to verify gradle is installed correctly on my Mac ?
A: use which to make sure can find gradle
➜ ~ which gradle
/Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin/gradle
AND to check and see gradle version
➜ ~ gradle --version
------------------------------------------------------------
Gradle 6.0.1
------------------------------------------------------------
Build time: 2019-11-18 20:25:01 UTC
Revision: fad121066a68c4701acd362daf4287a7c309a0f5
Kotlin: 1.3.50
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_112 (Oracle Corporation 25.112-b16)
OS: Mac OS X 10.14.6 x86_64
this means the (latest) gradle is correctly installed on your mac ^_^.
for more detail please refer my (Chinese) post 【已解决】mac中安装maven
I can't seem to get gradle to install on work on opensuse 13.2.
Installed by:
sudo unzip -oq gradle-2.2.1-all.zip -d /opt/gradle
sudo ln -sfn gradle-2.2.1 /opt/gradle/latest
export GRADLE_HOME=/opt/gradle/latest
export PATH=$GRADLE_HOME/bin:$PATH
running gradle:
$gradle -v
java.lang.NoClassDefFoundError: org.gradle.util.CollectionUtils
at java.lang.Class.initializeClass(libgcj.so.14)
at org.gradle.internal.classpath.DefaultClassPath.<init>(DefaultClassPath.java:37)
at org.gradle.api.internal.classpath.EffectiveClassPath.<init>(EffectiveClassPath.java:32)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.<init>(DefaultModuleRegistry.java:61)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.<init>(DefaultModuleRegistry.java:55)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:44)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/opt/gradle/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.Class.initializeClass(libgcj.so.14)
...7 more
Have you tried adding the symlink in /usr/bin?
Like this:
sudo ln -s /opt/gradle/latest/bin/gradle /usr/bin/gradle
It worked for me in openSuse 13.2
Make sure gradle is using Java 1.8
> $JAVA_HOME/bin/java -version
Should return
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (IcedTea 3.8.0) (build 1.8.0_171-b11 suse-24.1-x86_64)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
My box had $JAVA_HOME linked to Java 1.5
problem: when deploying my war to tomcat7 i get the error
java.lang.UnsupportedClassVersionError: org.MyLibraryClass : Unsupported major.minor version 51.0
(this is the error one gets when compiling java with a newer version than the java used when running the code.)
situation, in order:
brand new ubuntu 12.04.1 server 64bit minimal, in a virtualbox
installed tomcat6
tried to deploy my war
realized the error, and that i need java7 because ubuntu 12 still comes with outdated java
installed oracle java 7 using this guide https://askubuntu.com/questions/197248/java-on-ubuntu-server-12-04
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
removed tomcat6 and installed tomcat7
sudo apt-get remove tomcat6-common
sudo apt-get install tomcat7
deployed my war to tomcat7
started tomcat
sudo service tomcat7 start
checked my app's log file. same error.
echo $JAVA_HOME is empty, java -version shows:
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
it's a default tomcat7 install, no modification. still i checked the startup scripts and config to make sure no custom java version is specified anywhere. also checked by asking catalina:
ubuntu#ubuntu:/home$ /usr/share/tomcat7/bin/catalina.sh version
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Jul 19 2012 03:21:30
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.2.0-29-generic
Architecture: amd64
JVM Version: 1.7.0_07-b10
JVM Vendor: Oracle Corporation
now i'm stuck. i don't see how any java code could fail to run on oracle's jre7.
my war is a brand new very basic hello world grails 2.1 app with maven, which has a maven dependency (org.MyLibraryClass) that is compiled with jdk7. that's the one for which i get the error.
in grails i changed BuildConfig.groovy to have 1.7 instead of 1.6:
grails.project.target.level = 1.7
grails.project.source.level = 1.7
then did a grails clean, rebuild, war, redeploy. no change.
any idea what to try next?
Typical error when compiling code with Java7 and running it under Java6.
The critical line in your query is this one I think:
sudo service tomcat7 start
I think it may be triggering the inheritance of OpenJDK still in the system there. What you want to do is instead try tomcat from your own environment.
Login as your normal user
java -version
/usr/share/tomcat7/bin/startup.sh
and check. You should also login as a clean user, root or elsewhere and check java -version to check.
If all else fails, go to /etc/profile and make sure path to Oracle's Java/bin directory is the very first thing in the PATH variable for the environment.
I have the same problem just now,but now it's solved.
Please check this symbolic
/usr/lib/jvm/default-java
it's default link is open-jdk, reset the correct jdk dirctory.
good luck!
Where can I find a simple set of instructions to compile an OpenJDK 7 debug build on Ubuntu 11.10 (Oneiric)? A debug build would make more JVM options available for troubleshooting purposes; for example, WizardMode. The developers' guide and build README have a lot of noise and are hard to follow.
Install relevant packages:
sudo apt-get install ant build-essential openjdk-6-jdk
sudo apt-get build-dep openjdk-6-jdk
Find the master OpenJDK Mercurial repository you want to start from. These instructions will use jdk7u2.
Command examples contain settings to allow Internet access through a proxy server; remove them if they are unnecessary for you.
Clone the Mercurial top-level forest repository:
$ mkdir jdk7u2
$ cd jdk7u2
$ hg --config http_proxy.host=proxy:1234 clone http://hg.openjdk.java.net/jdk7u/jdk7u2 forest
$ cd forest
$ sh ./get_source.sh
The build will fail while compiling the sound libraries. As suggested here, use the following to patch the appropriate Makefile:
$ echo -e "--- old/jdk/make/javax/sound/jsoundalsa/Makefile 2012-01-28 12:00:00.000000000 -0500\n+++ new/jdk/make/javax/sound/jsoundalsa/Makefile 2012-01-28 12:00:00.000000000 -0500\n## -65,7 +65,7 ##\n \t\$(MIDIFILES_export) \\\\\n \t\$(PORTFILES_export)\n\n-LDFLAGS += -lasound\n+EXTRA_LIBS += -lasound\n \n CPPFLAGS += \\\\\n \t-DUSE_DAUDIO=TRUE \\\\" | patch -p1
Compile:
$ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=1234 -Dhttps.proxyHost=proxy -Dhttps.proxyPort=1234"
$ . jdk/make/jdk_generic_profile.sh
$ make ALLOW_DOWNLOADS=true fastdebug_build
The compile will take a while.
Verify the build:
$ build/linux-amd64-fastdebug/j2sdk-image/bin/java -version
openjdk version "1.7.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.7.0-internal-fastdebug-user_2012_01_28_13_25-b00)
OpenJDK 64-Bit Server VM (build 22.0-b10-fastdebug, mixed mode)
$ build/linux-amd64-fastdebug/j2sdk-image/bin/java -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -XX:+PrintFlagsWithComments -version
If you have problems along the way, begin by reading The OpenJDK Developers' Guide and the OpenJDK Build README.