1
votes

I am studying Ant scripts in Java reading this Hello World tutorial: http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

In the previous tutorial it create a new directory by DOS md src command (mkdir in Linux)

then put the following simple code into: src\oata\HelloWorld.java:

package oata;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

Now it compile it by this shell statment:

md build\classes
javac -sourcepath src -d build\classes src\oata\HelloWorld.java
java -cp build\classes oata.HelloWorld

I know that javac compile the classess but what exactly do this line?

javac -sourcepath src -d build\classes src\oata\HelloWorld.java

I think that I am sayng to javac that src is where are the sources class to compile, then the -d say that build\classes i the path where to put the compiled class

But what it means the final: src\oata\HelloWorld.java?

Tnx

Andrea

1

1 Answers

1
votes

It means the filename(s) to compile.

The purpose of the -sourcepath option is to tell the compiler where the source files for dependent classes may be found. It doesn't imply that everything in that directory should be compiled.