I have the following directory structure form where I am invoking javac
src/ lib/ build/
Under src:
Under lib:src/com/xyz/App.java -- contains the main class
src/com/xyz/base/j1.java src/com/xyz/base/j2.java src/com/xyz/exceptions/e1.java src/com/xyz/hibernate/factory/hbf1.java src/com/xyz/hibernate/helper/hbh1.java
At the top level, I am using the following javac command:lib/hibernate.jar
lib/commons.jar
javac -verbose -classpath lib/hibernate.jar:lib/commons.jar -d ./build -sourcepath ./src com/xyz/*.java
and I receive the following output
javac: No match
How should the args be passed to javac?
And here is the ANSWER:
javac -verbose -d build -classpath lib/commons.jar:lib/hibernate.jar [complete path for ALL the directories]/*.java
javac won't expand wildcards, that's what your shell does. so when you specify com/xyz/*.java , that will not expand to anything, as those files are under src/ but the shell doesn't know that. If you list out every java file as com/xyz/Foo.java com/xyz/Bar.java etc, it should work.
(note that if you're on windows you'll need ; and not : to seperate classpaths)
Something like this might work:
javac -verbose -classpath build:lib/hibernate.jar:lib/commons.jar -d ./build ./src/com/xyz/base/*java ./src/com/xyz/exceptions/*.java ./src/com/xyz/hibernate/factory/*.java ./src/com/xyz/*.java
I'd not do this other than as an exercise on how to compile from a command line, otherwise use a build tool like ant
精彩评论