" javac -d"不适用于mac osx

时间:2014-10-15 05:30:49

标签: java macos javac

我尝试在我的mac book上编译一个完整的目录java文件,但是它不起作用,同样的命令在windows上工作

javac -d /path/*.java

2 个答案:

答案 0 :(得分:1)

也许它与-d选项应该以目录作为参数这一事实有关,然后你仍然需要提供要编译的文件?

来自javac文档

-d directory

Set the destination directory for class files. The directory must already exist;
javac will not create it. If a class is part of a package, javac puts the class 
file in a subdirectory reflecting the package name, creating directories as 
needed. For example, if you specify -d C:\myclasses and the class is called 
com.mypackage.MyClass, then the class file is called 
C:\myclasses\com\mypackage\MyClass.class.

If -d is not specified, javac puts each class files in the same directory as the 
source file from which it was generated.

Note: The directory specified by -d is not automatically added to your user class 
path.

我的想象力可以相信windows命令扩展星号列表的情况,使得第一个匹配以某种方式作为-d参数传递,但它不会使其正确(或明智) )。

答案 1 :(得分:0)

$ javac -help

-d <directory>             Specify where to place generated class files

所以你使用了错误的选项。如果要指定包含要编译的.java文件的目录,请使用

-sourcepath <path>         Specify where to find input source files