Friday 24 May 2019

Compile multiple java files in one line


javac command support can take multiple java classes as input and generte .class files.

Syntax
javac Class1 Class2 .... ClassN

Example
javac Employee.java Student.java

$ls
Employee.java  PermanentEmployee.java Student.java
$
$javac Employee.java Student.java
$
$ls
Employee.class  Employee.java  PermanentEmployee.java Student.class  Student.java

Javac support wildcards
javac support wildcard characters.

For example,

javac *Employee.java statement compile all the classes whose name ends with Employee.

$rm *class
$ls
Employee.java  PermanentEmployee.java Student.java
$
$javac *Employee.java
$
$ls
Employee.class  Employee.java  PermanentEmployee.class PermanentEmployee.java Student.java


javac *java : compile all the classes in a directory.
$rm *class
$ls
Employee.java  PermanentEmployee.java Student.java
$
$javac *java
$
$ls
Employee.class  Employee.java  PermanentEmployee.class PermanentEmployee.java Student.class  Student.java
$


You may like


No comments:

Post a Comment