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

Exclude java.util.Currency from javac/build path

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am using Ant for compilation and build, my borrowed code has its own xxx.Currency which needs to be refered throughout the code and not java.util.Currency.


"This is present, not in few files but throughout the source code.....i dont know how the ex-developer could have built it 4 years ago like that....."
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than trying to get Ant to remove some classes from your class path, why not attack it from the code - side, which is better practice anyway (you no longer would be dependent of the build system in order to get correct code).

Your problem is that you need to use xxx.Currency instead of java.util.Currency. There are two solutions:
1) Don't import java.util.Currency into your source files. This would include NOT doing this:

Instead import the individual classes from the java.util package you need:


2) Use a fully qualified class name whenever referring to Currency. The fully qualified class name is the name of the package + dot + the name of the class. So java.util.Currency or my.app.money.Currency. Example:


I always try to do the first option (don't import 2 classes with the same name) whenever possible, but there are times when I need to fall back to the fully qualified names as well.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

abhijatalok alok wrote:i dont know how the ex-developer could have built it 4 years ago like that....."



java.util.Currency was added in Java 1.4 - maybe (s)he was using an earlier version.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question clearly demonstrates why importing complete packages with *, such as

is not a good idea, and why it is better to import only the classes that you need from a package.
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic