Reputation: 708
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!
Upvotes: 1
Views: 1858
Reputation: 9451
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:
Download the .jar file and copy it to the /libs/
folder in the application project;
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 ')}
;
Rebuild the project.
Upvotes: 2