Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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: 69884
278
  • 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.
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic