简体   繁体   English

将编译后的 class 文件添加到类路径中,以便在 java gradle 项目中导入

[英]Add compiled class files to classpath for import in java gradle project

I have a java project with gradle.我有一个带有 gradle 的 java 项目。 How to import external compiled class files (.class) into this project to use them.如何将外部编译的 class 文件(.class)导入此项目以使用它们。 Like adding compiled class files to classpath.就像将已编译的 class 文件添加到类路径一样。 with javac i just do javac -cp.使用 javac 我只是做 javac -cp。 somefile.java. somefile.java。 I am new with gradle so can someone give me solution.我是 gradle 的新手,所以有人可以给我解决方案。 Thank you.谢谢你。

Firstly, it is never recommended to add class files in this manner, but it does not stop from doing so首先,不建议以这种方式添加 class 文件,但它并没有停止这样做

compileJava.classpath = compileJava.classpath + files(file("$project.rootDir/lib"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “.java 不在项目的类路径中,不会编译为.class 文件”错误 - ".java is not on the classpath of project, it will not be compiled to a .class file" error 如何将缺少.project .settings .classpath文件的java项目导入到eclipse中 - How to import a java project missing .project .settings .classpath files into eclipse App.java 不在项目 ss_d36b3017 的类路径上,不会编译成 a.class 文件Java(32) - App.java is not on the classpath of project ss_d36b3017, it will not be compiled to a .class fileJava(32) 如何在Gradle中将根项目添加为类路径 - How to add root Project as classpath in Gradle 在Java 8的gradle中的jar清单文件中添加Classpath - Add Classpath in Manifest file of jar in gradle in java 8 Gradle (java):测试任务应该使用生成的 .jar 而不是类路径中的 .class 文件 - Gradle (java): test task should use generated .jar and not the .class files in classpath Gradle没有加载从buildrc中放置的Java源编译的Java类文件 - Gradle not loading Java class files compiled from Java source placed in buildsrc Gradle自定义插件:读取编译的Java类 - Gradle Custom Plugins: Read Compiled Java Class Gradle项目中无法识别类路径 - Classpath Not Recognized in Gradle Project Ant:将一个编译的类文件添加到javac类路径? - Ant: add a single compiled class file to javac classpath?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM