简体   繁体   中英

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:

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!

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 -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). You can let javac write them to a new place using the option -d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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