9

I'm working on a very large project that has associated class files in multiple directories, all stemming from the root dir \src.

I'm trying to compile a file in src\solution\ (called Console.java) that uses imports from other directories in the src, which are still uncompiled.

So if I want to compile Console.java outside of an IDE, how do I go about doing that? Oh yeah, I also have some external JARs which need to be included in the build.

Thanks! I appreciate it!

Monster
  • 1,573
  • 6
  • 23
  • 35
  • possible duplicate of [javac option to compile all java files under a given directory recursively](http://stackoverflow.com/questions/6623161/javac-option-to-compile-all-java-files-under-a-given-directory-recursively) – Ciro Santilli OurBigBook.com Apr 08 '15 at 14:48

4 Answers4

5

I would look at using Ant to create a build script. It's a little bit of work now but it'll pay off over the lifetime of your project.

mtpettyp
  • 5,533
  • 1
  • 33
  • 33
2

javac comes with two options, that might help you her:

-c path/to/one/jar;path/to/another/jar
for libraries and
-s path/to/src/solution/java;path/to/src/test/java
for sourcefiles. It's worth a try.
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • 1
    But this way (-s); I have to give all the folder names which contains java files rit ..? If i give root dir; Doesn't wont go search (.java) in sub directories for dependencies? – Kanagavelu Sugumar Jul 02 '13 at 08:50
1

I'm a little unclear on your specific requirements, but what your asking is almost certainly possible. You might want to take a look at the javac options, and see what you can find that will help you.

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#options

For example, for the external .jars you need, those need to be included in your classpath using the -classpath option.

shsteimer
  • 28,436
  • 30
  • 79
  • 95
1

You definitely want a build tool. You might want to look at these questions:

Community
  • 1
  • 1
NamshubWriter
  • 23,549
  • 2
  • 41
  • 59