简体   繁体   English

Javac - 在不同目录中编译.java文件

[英]Javac - Compile .java files in different directories

I'm creating a Submission System where I would like the Framework files in a fixed location on the server - a user will upload their file in a different directory. 我正在创建一个提交系统,我希望框架文件位于服务器上的固定位置 - 用户将其文件上载到不同的目录中。

If I'm just working with .class files, then the following command works when executed: 如果我只是使用.class文件,则以下命令在执行时有效:

java -cp /SubmissionSystem/Java/Assessment/Framework:/SubmissionSystem/Java/Assessment/Test Assessment4 java -cp / SubmissionSystem / Java / Assessment / Framework:/ SubmissionSystem / Java / Assessment / Test Assessment4

I was wondering whether there is a similar command that can be called to compile the .java files in different directories instead of .class files! 我想知道是否有一个类似的命令可以被调用来编译不同目录中的.java文件而不是.class文件!

I'd appreciate any help! 我很感激任何帮助!

Yes, just replace java with javac and instead of passing the folder with the sources to the -classpath option, pass it to -sourcepath : 是的,只需用javac替换java ,而不是将包含源的文件夹传递给-classpath选项,将其传递给-sourcepath

javac -cp /SubmissionSystem/Java/Assessment/Framework -sourcepath "/SubmissionSystem/Java/Assessment/Test Assessment4"

Don't forget proper quoting when the paths contain spaces. 当路径包含空格时,不要忘记正确的引用。 That will compile the files in place (so they will mix with the .java source files). 这将编译文件(因此它们将与.java源文件混合)。 You can let javac write them to a new place using the option -d 您可以使用选项-djavac写入新位置

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

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