• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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

 
Ranch Hand
Posts: 244
  • 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
 
Marshal
Posts: 66612
251
  • 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).
 
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.
 
straws are for suckers. tiny ads are for attractive people.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!