I am trying to use Java 11 for my Java Homework. It works fine on my OS X machine, but I have JDK 13 installed on my machine. My instructor uses Ubuntu and does not have the latest java installed. How Can I get Bazel to use JAVA 11 without requiring my instructor to update his JDK.
My .bazelrc is as follows:
test --test_output=errors
test --cache_test_results=yes
test --java_toolchain=#bazel_tools//tools/jdk:toolchain_java11
And when I run:
bazel test java/test/edu/berkeley/cs/util:{hashset,hashmap}
I get this wonderfull error.
Starting local Bazel server and connecting to it...
INFO: Writing tracer profile to '/home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/command.profile.gz'
INFO: Analyzed 2 targets (23 packages loaded, 287 targets configured).
INFO: Found 2 test targets...
INFO: Deleting stale sandbox base /home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/sandbox
ERROR: /home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/external/bazel_tools/tools/jdk/BUILD:319:1: Action external/bazel_tools/tools/jdk/platformclasspath.jar failed (Exit 1) java failed: error executing command external/remotejdk11_linux/bin/java -XX:+IgnoreUnrecognizedVMOptions '--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED' -cp ... (remaining 4 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
Exception in thread "main" java.lang.IllegalArgumentException: external/local_jdk
at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.isCurrentPlatform(Locations.java:1862)
at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.update(Locations.java:1851)
at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.handleOption(Locations.java:1798)
at jdk.compiler/com.sun.tools.javac.file.Locations.handleOption(Locations.java:2062)
at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:269)
at jdk.compiler/com.sun.tools.javac.file.BaseFileManager$2.handleFileManagerOption(BaseFileManager.java:222)
at jdk.compiler/com.sun.tools.javac.main.Option.process(Option.java:1138)
at jdk.compiler/com.sun.tools.javac.main.Option.handleOption(Option.java:1086)
at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:232)
at jdk.compiler/com.sun.tools.javac.main.Arguments.doProcessArgs(Arguments.java:390)
at jdk.compiler/com.sun.tools.javac.main.Arguments.processArgs(Arguments.java:347)
at jdk.compiler/com.sun.tools.javac.main.Arguments.init(Arguments.java:246)
at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:185)
at DumpPlatformClassPath.dumpJDK9AndNewerBootClassPath(DumpPlatformClassPath.java:106)
at DumpPlatformClassPath.main(DumpPlatformClassPath.java:67)
Caused by: java.nio.file.NoSuchFileException: external/local_jdk
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.isSameFile(UnixFileSystemProvider.java:333)
at java.base/java.nio.file.Files.isSameFile(Files.java:1530)
at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.isCurrentPlatform(Locations.java:1860)
... 14 more
INFO: Elapsed time: 8.063s, Critical Path: 0.26s
INFO: 3 processes: 3 linux-sandbox.
FAILED: Build did NOT complete successfully
//java/test/edu/berkeley/cs/util:hashset NO STATUS
FAILED: Build did NOT complete successfully
If anyone can solve this will be glad to send you a bag of Blue Bottle beans or something similar that costs $20 =D
I don't know I understand your question correctly, but I'm looking for the same issue right now.
So far I got one answer from this link from Bazel Dev! from gerrit.googlesource.com
And please look at this section:
[[java-11]]
==== Java 11 support
Java 11 is supported through alternative java toolchain
link:https://docs.bazel.build/versions/master/toolchains.html[Bazel option].
To build Gerrit with Java 11, specify JDK 11 java toolchain:
$ bazel build \
--host_javabase=#bazel_tools//tools/jdk:remote_jdk11 \
--javabase=#bazel_tools//tools/jdk:remote_jdk11 \
--host_java_toolchain=#bazel_tools//tools/jdk:toolchain_java11 \
--java_toolchain=#bazel_tools//tools/jdk:toolchain_java11 \
:release
Related
I am learning Spring Boot and am working through this example using Intellij.
Problem:
Intellij's Bazel button --> errors (see example below)
This is the small green icon top right "Sync Project with BUILD Files"
#CrossOrigin annotation causes the error during sandbox compilation or something.
Running command manually bazel build //src/main/java/hello:app --> builds just fine
My understanding of the problem so far:
Intellij's bazel build command includes a flag, --output_groups=intellij-resolve-java-direct-deps, that checks implicit dependencies (see full command + error below).
Normal bazel build //src/main/java/hello:app obviously doesn't include this flag and builds + runs fine.
Questions:
Does anyone know what exactly this flag does?
The error is confusing, stating that it's looking for "another annotation parameter" but I don't believe this to be accurate. If not, what exactly is the parameter I'm supposed to supply? ...and what is <clinit>?
Error Command + Output
/usr/bin/bazel build --tool_tag=ijwb:IDEA:community --keep_going --build_event_binary_file=/tmp/intellij-bep-ef1a54af-ac18-480c-b813-050e261d0a4f --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --noexperimental_run_validations --aspects=#intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=/home/jordan/.local/share/JetBrains/IdeaIC2021.2/ijwb/aspect --output_groups=intellij-resolve-java-direct-deps -- //src/main/java/hello:app
Loading:
Loading: 0 packages loaded
Analyzing: target //src/main/java/hello:app (0 packages loaded, 0 targets configured)
INFO: Analyzed target //src/main/java/hello:app (5 packages loaded, 184 targets configured).
INFO: Found 1 target...
[0 / 39] [Prepa] BazelWorkspaceStatusAction stable-status.txt
ERROR: /home/jordan/Documents/swe/rules_jvm_external/examples/spring_boot/src/main/java/hello/BUILD:1:13: Compiling Java headers src/main/java/hello/liblib-hjar.jar (2 source files) failed: (Exit 1): java failed: error executing command external/remotejdk11_linux/bin/java -Xverify:none -XX:+UseParallelOldGC -XX:-CompactStrings '--patch-module=java.compiler=external/remote_java_tools_linux/java_tools/java_compiler.jar' ... (remaining 42 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
src/main/java/hello/HelloController.java:7: error: missing required annotation argument: <clinit>
#CrossOrigin
^
src/main/java/hello/HelloController.java:11: error: missing required annotation argument: <clinit>
#CrossOrigin
^
Aspect #intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect of //src/main/java/hello:app failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.460s, Critical Path: 0.33s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
INFO: Build Event Protocol files produced successfully.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
Successful Command + Output
(removed flag --output_groups=intellij-resolve-java-direct-deps)
/usr/bin/bazel build --tool_tag=ijwb:IDEA:community --keep_going --build_event_binary_file=/tmp/intellij-bep-ef1a54af-ac18-480c-b813-050e261d0a4f --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --noexperimental_run_validations --aspects=#intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=/home/jordan/.local/share/JetBrains/IdeaIC2021.2/ijwb/aspect -- //src/main/java/hello:app
Loading:
Loading: 0 packages loaded
Analyzing: target //src/main/java/hello:app (0 packages loaded, 0 targets configured)
INFO: Analyzed target //src/main/java/hello:app (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Aspect #intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect of //src/main/java/hello:app up-to-date (nothing to build)
INFO: Elapsed time: 0.034s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 1 total action
Bazel is still working to support Java 11 and there are Java annotation processors which appear to be hardcoded to JDK 8.
See this GitHub issue which refers to a
Temporary fix
--java_header_compilation=false
Note that this won't solve the issue when using Intellij's bazel button. This will only fix running the command manually (with the --java_header_compilation=false flag).
Long-term fix in the upcoming release (6.0.0)
I installed the pre-release 6.0.0 Bazel from the source code using these directions, which includes the implemented fix. This solved the problem. Now I can use two different releases of bazel - 6.0.0 by calling bazel_dev or the latest main release (4.2.1) by simply calling bazel.
Point to /some/path/to/bazel_dev binary in Intellij's Bazel settings.
I have installed docker then java image then jenkins image, now installing its dependencies, gives following error in logs, any Idea how can it be resolved, as I am from rails background so don't have much knowledge about java error and exceptions, please provide suggestions.
May 31, 2020 9:41:30 AM hudson.model.UpdateCenter$DownloadJob run
INFO: Starting the installation of Pipeline: Job on behalf of admin
May 31, 2020 9:41:32 AM hudson.model.UpdateCenter$UpdateCenterConfiguration download
INFO: Downloading Pipeline: Job
May 31, 2020 9:41:33 AM hudson.PluginManager dynamicLoad
INFO: Attempting to dynamic load /var/jenkins_home/plugins/workflow-job.jpi
May 31, 2020 9:41:33 AM hudson.model.UpdateCenter$DownloadJob run
SEVERE: Failed to install Pipeline: Job
java.io.IOException: Failed to dynamically deploy this plugin
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1893)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1651)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Failed to install workflow-job plugin
at hudson.PluginManager.dynamicLoad(PluginManager.java:874)
at hudson.PluginManager.dynamicLoad(PluginManager.java:813)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1889)
... 5 more
Caused by: java.io.IOException: Pipeline: Job v2.39 failed to load.
- You must update Jenkins from v2.60.3 to v2.138.4 or later to run this plugin.
- Pipeline: API v2.40 failed to load. Fix this plugin first.
at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:626)
at hudson.PluginManager.dynamicLoad(PluginManager.java:864)
... 7 more
Which Jenkins version did you install?
It seems like plugins not supporting on outdated Jenkins version.
Try to skip plugin installation from 'Getting Started' and install them later.
Also, you can try to use official Jenkins docker images.
https://www.jenkins.io/blog/2018/12/10/the-official-Docker-image/
I had same issue and tried with v2.60.3 and other version as well.
LTS version works and installs plugin.
$ docker pull jenkins/jenkins:lts
$ docker run -p 8080:8080 -p 50000:50000 --name myjenkins jenkins/jenkins:lts
there's deprecation notice in the page as following https://hub.docker.com/_/jenkins?tab=description
I had the same issue, and it's because there was old jenkins configuration in folder "/home/user/.jenkins/" , just delete it o backup it, in order when you new Jenkins Installation start, it going to create a new ".jenkins/" folder with empty conf.
And don't forget that you really has deinstalled old jenkins version.
Prior to upgrading to Fedora 24, I would see output from Gradle like the following:
> Loading
> Configuring project 0/20
> Executing test 39 of 4049, 12 skipped.
I've read that users often set TERM=dumb in order to disable this output; however, my TERM environment variable is set to xterm-256color.
Could someone tell me what I need to set or change under Fedora 24 (which seemed to exist in Fedora 23) to allow me to get this Gradle output?
The problem is that Gradle is wanting to use ncurses5 where it seems Fedora 24 install comes with a newer version, thus causing the issue. This can be seen by running gradle --debug and seeing the following output:
[DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Unable to load from native-platform backed Consol
eDetector. Continuing with fallback. Failure: net.rubygrapefruit.platform.NativeException: Failed to load native library 'libnative-pl
atform-curses.so' for Linux amd64.
caused by: java.lang.UnsatisfiedLinkError: /home/dkowis/.gradle/native/19/linux-amd64/libnative-platform-curses.so: libncurses.so.5: c
annot open shared object file: No such file or directory
The temporary solution is to create a symbolic link to the new libncurses.so.6 library as follows:
sudo ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
After doing this, Gradle now outputs the build status text as it did previously.
I'm trying my hand at Scala for the first time, and I've chosen to do so using SBT 0.13.9 on a Linux machine running a new install of Ubuntu 14.04LTS.
I've been following the instructions given on the SBT website to the letter, and I'm now trying to run the "Hello!" example script, which is as follows:
object Hi {
def main(args: Array[String]) = println("Hi!")
}
When I try to run, I get the following output:
[trace] Stack trace suppressed: run last compile:compileIncremental for the full output.
[error] (compile:compileIncremental) java.lang.NullPointerException
[error] Total time: 1 s, completed 22 Aug 2015, 2:30:09 PM
Being completely new to Scala and SBT (and also relatively new to Linux) I'm sure I've just overlooked something obvious. No amount of Googling has yielded any answers so far though.
What should I check first? I'd really appreciate any advice anyone can offer.
I had the same error, on exactly the same code snippet! ie the first one in the scala sbt getting started hello.html
My problem was resolved when i uninstalled the java 9 sdk and installed the java 8 sdk.
Doing this required that i also had to then re-install scala and sbt.
These I installed with the instructions from HERE but replacing the version numbers in the commands with scala-2.11.7.deb and sbt-0.13.9.deb (my dev machine being on ubuntu 14.04)
I have a problem with setting up the work environment for Cordova on Windows 7 for Android. I use NetBeans 8 and followed this guide: Link Here
New project -> Cordova -> Hello World Template.
Whenever I try to build a Cordova project (in NetBeans) I get this message:
BUILD FAILED
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml
Total time: 0 seconds
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\node_modules\q\q.js:126
throw e;
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Command finished with error code 8: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat --emulator
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\nbproject\build.xml:272: exec returned: 1
BUILD FAILED (total time: 47 seconds)
I have googled it for hours but can't seem to find a solution. Some people get some of the same errors(not exact, but similar), but the solutions did not work for me. One issue was regarding Java 8 and ant versions beneath 1.9.0 (I use Node 0.10.26, java 1.7.0_25, cordova 3.5.0-0.2.4 and ant 1.9.4). I also tried to create a new project with the console (CMD), but it gives the exact same error when I build. It's no problem to create the project, nor adding Android as a platform, the problem is building the project. I think the environment variables are set correctly since the java, node, ant and cordova commands work fine in cmd/powershell, and the check_reqs.bat said that the environment was fine.
It's this line that creates the error: <import file="${sdk.dir}/tools/ant/build.xml" />. This is the rest of the message: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml.
Here is the error I get in the command window (not using NetBeans):
PS C:\Users\Administrator\Desktop\test\fakeApp> cordova build android
Running command: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat
Buildfile: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml
BUILD FAILED
C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\
Skolegang\Dataingeni├©r\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Admini
strator\Desktop\test\fakeApp\platforms\android\build.xml
Total time: 0 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Desktop\test\fakeApp\platforms\androi
d\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\s
rc\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
I thought maybe it was a path issue since I have a special letter in the path were the NetBeansProjects are stored (and it's pretty long too), but creating a test directory at C:\ and creating the project with the command window gave the same error. I'm new at Cordova so I'm sure there's an easy solution, thanks in advance.
I solved it, though I tried to create a cordova project outside the OneDrive folder I did not think of the SDK path (which also were stored in OneDrive). By moving the SDK files to C: (the path could probably not contain the special letter 'ø') and changing the path of the environment variables (and the SDK path in NetBeans) it now runs perfectly.