英文:
Can't compile .h file in console with javac and lombok. Error: package lombok does not exist
问题
我需要为基于JNI的本地库编译.h文件。在我向项目中添加了一些Lombok注解后,我无法使用javac编译.h文件。我正在使用IntelliJ和Gradle。我尝试在IDE控制台中执行以下命令:
javac -h jni src/java/main/com/my/project/*.java
但是会得到错误:
src/java/main/com/my/project/Appjava:3: error: package lombok does not exist
import lombok.AccessLevel;
^
src/java/main/com/my/project/App.java:4: error: package lombok does not exist
import lombok.RequiredArgsConstructor;
^
src/java/main/com/my/project/App.java:5: error: package lombok does not exist
import lombok.Value;
以及其他类中的许多类似错误。App类中的第3、4和5行:
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Value;
在构建的Gradle中:
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
同时启用了注解处理,并安装了Lombok插件。我可以在IDE中构建项目,但无法执行javac命令。我该如何修复这个问题?
英文:
I need to compile .h file for my native library based on JNI. After I add some lombok annotations to my project I can't compile .h file with javac. I'm using IntelliJ and grade. I'm trying to perform next command in ide console:
javac -h jni src/java/main/com/my/project/*.java
And get error:
src/java/main/com/my/project/Appjava:3: error: package lombok does not
exist import lombok.AccessLevel;
^
src/java/main/com/my/project/App.java:4: error: package lombok does not exist import lombok.RequiredArgsConstructor;
^
src/java/main/com/my/project/App.java:5: error: package lombok >does not exist import lombok.Value;
and many similar errors in other classes. 3, 4 and 5 lines in App class:
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Value;
in build gradle:
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
Also annotation processing enabled and lombok plugin installed. I can build project in my ide but can't perform command javac. How I can fix it?
答案1
得分: 2
如果您在命令行上运行 javac
,则 Gradle 不会起作用;您需要传递类路径 -cp <all_jars>
。
英文:
if you are running javac
on command line then the gradle won't come into play; you will need to pass the classpath -cp <all_jars>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论