5 Replies Latest reply: Sep 27, 2007 12:35 AM by 807605 RSS

    Multiple Java File Compilation

    807605
      i have a root Package 'com'
      Under that there are 2 packages 'ui' and 'uti'
      so the whole thing looks so
      com.ui
      com.util

      i have 2 java classes both in the packages
      com.ui.Class1
      com.util.Class2

      My root folder is c:/work/src
      +src
      +com
      ---ui
      ------Class1.java
      ---util
      ------Class2.java

      i want to compile the whole src file at ones in {color:#ff0000}COMMAND LINE{color}( WITH OUT USING ID`S...)
      Please Provide Some Help

      Edited by: Arun.Aravind on Sep 26, 2007 9:40 PM
        • 1. Re: Multiple Java File Compilation
          807605
          Check Apache Ant

          http://ant.apache.org/manual/CoreTasks/javac.html
          • 2. Re: Multiple Java File Compilation
            807605
            Any one please give me the COMMAND LINE ARGUMENT
            like > javac -d . com/*.java

            Edited by: Arun.Aravind on Sep 26, 2007 9:56 PM
            • 3. Re: Multiple Java File Compilation
              jwenting
              that is indeed "the command line argument".

              What more do you want? Compile a class and every class using it that needs compiling is also compiled (if the compiler can find the source, if not you get an error).
              • 4. Re: Multiple Java File Compilation
                807605
                This may help..

                http://www.vipan.com/htdocs/javahelp.html
                • 5. Re: Multiple Java File Compilation
                  807605
                  A few things:

                  (1) Your original post is not clear. You have a com directory (with the .java files below it) alongside the src directory. Is this what you really mean? Most people would put the .java files (which are source files...) beneath the src directory.

                  (2) Where you want the .class files to end up - alongside the source files, or somewhere else?

                  (3) What OS/shell are you using? It's a bit hard to give command line commands without knowing this.

                  Here's an example that might help:
                   pbrockway@linuxdeskd6off:~/JDC/eg$ ls -R\\ .:\\ build  src
                  ./build:
                  ./src:\\ com
                  ./src/com:\\ ui  util
                  ./src/com/ui:\\ Class1.java
                  ./src/com/util:\\ Class2.java\\ pbrockway@linuxdeskd6off:~/JDC/eg$ javac -d build -cp build -sourcepath src src/com/ui/Class1.java src/com/util/Class2.java\\ pbrockway@linuxdeskd6off:~/JDC/eg$ ls -R\\ .:\\ build  src
                  ./build:\\ com
                  ./build/com:\\ ui  util
                  ./build/com/ui:\\ Class1.class
                  ./build/com/util:\\ Class2.class
                  ./src:\\ com
                  ./src/com:\\ ui  util
                  ./src/com/ui:\\ Class1.java
                  ./src/com/util:\\ Class2.java\\ pbrockway@linuxdeskd6off:~/JDC/eg$
                  This compiles the two classes and puts the resulting files into a structure rooted at build. It specifies the sourcepath, output directory and classpath to be used.

                  Details here: http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html

                  Ant is very good for tasks like this. Although capable of very complex build tasks it scales well and does simple things simply.