• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Compiling java files in different packages with single javac command

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic