Compile all files in src?

Here's what I've got:

/myjava/compile.cmd
/myjava/src/a/HelloWorld.java
/myjava/src/b/Inner.java
/myjava/src/b/Inner2.java
/myjava/bin

HelloWorld:

package a_pack;

import b_pack.Inner;
import b_back.Inner2; 

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello, World");     

        Inner myInner = new Inner(); 
        myInner.myInner(); 

        Inner2 myInner2 = new Inner2();
        myInner2.myInner(); 

    }

}

Inner.java

package b_pack; 

public class Inner {

    public void myInner() {
        System.out.println("Inner Method");
    }

}

Inner2.java

package b_pack; 

public class Inner2 {

    public void myInner() {
        System.out.println("SecondInner");
    }

}

Now what I'm trying to do is compile this so I can run.

I could compile it with:

javac -d bin src/a/HelloWorld.java src/b/Inner.java src/b/Inner2.java

But I want to use a generic command that doesn't require listing every subfolder. How do I do this?


由于HelloWorld类将引用导入InnerInner2类,因此可以使用javac sourcepath标志来编译所有这三个类:

javac -d bin -sourcepath src src/a/HelloWorld.java
链接地址: http://www.djcxy.com/p/96754.html

上一篇: Java Decompiler生成抽象枚举

下一篇: 编译src中的所有文件?