• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79670
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic