Answer a question

I'm working with Java in VS Code. I imported time4j lib into my project and when I try to compile the project the errors occur:

Executing task: gradlew build   -Dorg.gradle.java.home="C:\Users\Public\wpilib\2020\jdk" <


> Task :compileJava FAILED
D:\Scripts\Java\Java_4\src\main\java\frc\robot\subsystems\PID.java:5: error: package net.time4j does not exist
import net.time4j.SystemClock;
                 ^
D:\Scripts\Java\Java_4\src\main\java\frc\robot\subsystems\PID.java:6: error: package net.time4j does not exist
import net.time4j.TemporalType;
                 ^
D:\Scripts\Java\Java_4\src\main\java\frc\robot\subsystems\PID.java:43: error: cannot find symbol
        this.clock = TemporalType.CLOCK.from(SystemClock.MONOTONIC);
                                             ^
  symbol:   variable SystemClock
  location: class PID
D:\Scripts\Java\Java_4\src\main\java\frc\robot\subsystems\PID.java:43: error: package TemporalType does not exist
        this.clock = TemporalType.CLOCK.from(SystemClock.MONOTONIC);
                                 ^
4 errors
Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileJava).
Check that all your files are saved, then scroll up in this log for more information.

FAILURE: Build failed with an exception.

But when I was writing the program there was no any errors and time4j was ok! I'm new in java and I don't understand what I'm doing wrong. Thanks!

Answers

First, check the referenced path of time4j and make it right because the error was package net.time4j does not exist;

If it does exist, we can try:

  1. Download the .jar file and copy it to the /libs/ folder in the application project;

  2. Open at the root level of the project build.gradle File and edit the dependency to include the new .Jar file: dependency {compile filetree (DIR: 'libs', include:' *. Jar ')};

  3. Rebuild the project.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐