| Author |
Compiling java files in different packages with single javac command
|
Thomas Greene
Ranch Hand
Joined: Aug 09, 2004
Posts: 125
|
|
i have java files in various package such as com\pack1\pack2\pack3\one com\pack1\pack2\pack3\one\a com\pack1\pack2\pack3\one\a\b com\pack1\pack2\pack3\one\a\b\c com\pack1\pack2\pack3\two com\pack1\pack2\pack3\two\a com\pack1\pack2\pack3\two\b com\pack1\pack2\pack3\two\c I am compiling them as javac com\pack1\pack2\pack3\one\*.java javac com\pack1\pack2\pack3\one\a\*.java javac com\pack1\pack2\pack3\one\a\b\*.java .. javac com\pack1\pack2\pack3\two\*.java I want to know is it possible to compile them with a single javac command(or may be lesser number of javac commands) thanks
|
 |
Ta Ri Ki Sun
Ranch Hand
Joined: Mar 26, 2002
Posts: 442
|
|
there's a million and 1 ways, of which I like ant the most. but if you must here's some info...
FILE LIST To shorten or simplify the javac command, you may specify one or more files that themselves contain one filename per line. On the command line, use the '@' character with the filename to specify it as a file list. When javac encounters an argument beginning with the character `@', it operates on the filenames in that file as if they had been on the command line. This enables you to overcome the command-line length limitation of Windows. For example, you can list all of the source file names in a file named sourcefiles. This file might look like: MyClass1.java MyClass2.java MyClass3.java You could then run the compiler with: C:> javac @sourcefiles
or...
-sourcepath sourcepath Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by semicolons (  and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name.
click for more info on javac
|
 |
Rajan Chinna
Ranch Hand
Joined: Jul 01, 2004
Posts: 320
|
|
You can also create DOS batch file and run it Ex: c:\>copy con compile.bat javac com\pack1\pack2\pack3\one\*.java javac com\pack1\pack2\pack3\one\a\*.java javac com\pack1\pack2\pack3\one\a\b\*.java ^z c:\>compile
|
 |
Rovas Kram
Ranch Hand
Joined: Aug 08, 2003
Posts: 135
|
|
You can also use this syntax: javac com\pack1\pack2\pack3\one\*.java com\pack1\pack2\pack3\one\a\*.java com\pack1\pack2\pack3\one\a\b\*.java This is a good choice becase the compiler will take care of interdependancy of the classes.
|
 |
 |
|
|
subject: Compiling java files in different packages with single javac command
|
|
|