Building Java package (javac to all files)

后端 未结 3 2132
温柔的废话
温柔的废话 2021-02-07 14:10

How to compile all files in directory to *.class files?

3条回答
  •  名媛妹妹
    2021-02-07 14:37

    Yet another way using "find" on UNIX is described here:

    http://stas-blogspot.blogspot.com/2010/01/compile-recursively-with-javac.html

    The following two commands will compile all .java files contained within the directory ./src and its subdirectories:

    find ./src -name *.java > sources_list.txt
    javac -classpath "${CLASSPATH}" @sources_list.txt
    

    First, find generates sources_list.txt, a file that contains the paths to the Java source files. Next, javac compiles all these sources using the syntax @sources_list.txt.

提交回复
热议问题