简体   繁体   English

从命令行编译 Java 应用程序,包括项目和库文件

[英]Compile java application from command line including project and library files

I have java project like this.我有这样的java项目。 I want to compile using javac(from command line).我想使用 javac(从命令行)进行编译。 Can someone write exact example how to do this?有人可以写出具体的例子如何做到这一点吗? It should take account all project files and all libraries provided under lib1 and lib2.它应该考虑在 lib1 和 lib2 下提供的所有项目文件和所有库。 All examples i have searched so far are useless到目前为止我搜索过的所有例子都是无用的

com.company.main
    Main.java
com.company.main.utils
   DoSomethingUtil.java

libraries图书馆

lib1/*.jar
lib2/*.jar

This worked for me.这对我有用。 Hope it helps to someone希望对某人有帮助

//save into files
find  /javafiles-root-location/  -name "*.java" > build/source.txt
find  /libraries-location/* /libraries-location2/*  -name "*.jar" | paste -sd ":" > build/libs.txt

//then compile
javac @build/source.txt -d build/compiled/ -cp @build/libs.txt

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM