• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compile multiple java file in different package with one script?  RSS feed

 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can somebody tell me how to compile multiple java file in different package with one script without using ant script.

i.e

packege1 :- A1.java,B1.java
packege2 :- A2.java,B2.java
packege3 :- A3.java,B3.java

I want to compile all the files in one shot without using ant script.

Thanks in advance,

Kousik
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably don't need a script. If all your classes start off in the same folder, try

javac -d . A1.java A2.java A3.java B1.java B2.java B3.java

I have only got it to work once without packages, but it should work. The -d option mean to create directories (if required) and the . means start in the current directory (for source).
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:

javac -d . A1.java A2.java A3.java B1.java B2.java B3.java


You can do the same with "*.java" instead of appending all the .java files individually.


I have only got it to work once without packages, but it should work. The -d option mean to create directories (if required) and the . means start in the current directory (for source).


It does not work for the classes inside packages! It just works fine for the classes without packages ie., classes belonging to default packages.

I tried with the "-sourcepath" option in "javac" command with various values but no luck!

We need to find a work around for the same.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!