简体   繁体   English

我可以使用JAVAC编译包含多个文件和目录的项目吗?

[英]Can I use JAVAC to compile a project with multiple files and directories?

I'm working on a very large project that has associated class files in multiple directories, all stemming from the root dir \\src. 我正在开发一个非常大的项目,它在多个目录中关联了类文件,所有这些都来自root目录\\ src。

I'm trying to compile a file in src\\solution\\ (called Console.java) that uses imports from other directories in the src, which are still uncompiled. 我正在尝试在src \\ solution \\(称为Console.java)中编译一个文件,该文件使用src中其他目录的导入,这些目录仍然是未编译的。

So if I want to compile Console.java outside of an IDE, how do I go about doing that? 因此,如果我想在IDE之外编译Console.java,我该如何去做呢? Oh yeah, I also have some external JARs which need to be included in the build. 哦,是的,我还有一些需要包含在构建中的外部JAR。

Thanks! 谢谢! I appreciate it! 我很感激!

I would look at using Ant to create a build script. 我会看看使用Ant来创建构建脚本。 It's a little bit of work now but it'll pay off over the lifetime of your project. 现在这是一些工作,但它会在你的项目的整个生命周期中得到回报。

javac comes with two options, that might help you her: javac有两个选项,可能会帮助你:

-c path/to/one/jar;path/to/another/jar
for libraries and 对于图书馆和
 -s path/to/src/solution/java;path/to/src/test/java -s path / to / src / solution / java; path / to / src / test / java 
for sourcefiles. 对于源文件。 It's worth a try. 值得一试。

I'm a little unclear on your specific requirements, but what your asking is almost certainly possible. 我对你的具体要求有点不清楚,但你的要求几乎肯定是可能的。 You might want to take a look at the javac options, and see what you can find that will help you. 您可能需要查看javac选项,并查看可以帮助您的内容。

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#options http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#options

For example, for the external .jars you need, those need to be included in your classpath using the -classpath option. 例如,对于您需要的外部.jars,需要使用-classpath选项将它们包含在类路径中。

暂无
暂无

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

相关问题 javac:如何在多个目录中编译多个类? - javac: how to compile multiple classes in multiple directories? Javac - 在不同目录中编译.java文件 - Javac - Compile .java files in different directories 使用javac从不同目录编译文件,引用依赖的jar文件? - compile files from different directories with javac, referring a depending jar file? Javac-在不同目录的TTM代码中编译.java文件 - Javac - Compile .java files in different directories TTM code 当我使用javac命令编译许多具有一些错误的相关* .java文件时,如何从正确的* .java文件生成* .classes? - How can I get *.classes generated by the correct *.java files when I use javac command to compile many dependent *.java files with a few errors? Javac如何用于多个文件,目录,类和源? - How does Javac work for multiple files, directories, classes and source? 如何使用javac交叉编译旧测试以与Java 8兼容? - How can I use javac to cross compile my old tests to be compatible with java 8? 为什么我们需要让javac编译多个源文件? - Why do we need to ask javac to compile multiple source files? 使用Eclipse IDE可以完美地编译和运行Java程序,但是当我使用“ javac”时,会导致错误 - Using Eclipse IDE can compile and run the Java program perfectly but when I use 'javac' it is resulting to Error Intellij 可以构建我的项目,但 javac 无法编译/查找符号 - Intellij can build my project but javac cannot compile/find symbol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM