Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes jar interdependencies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar interdependencies" Watch "jar interdependencies" New topic
Author

jar interdependencies

jaffrin abdul salam
Greenhorn

Joined: Sep 16, 2005
Posts: 23
hi everyone,
I was given some java Batch program to work on.They asked me to find out the libraries needed for the batch program.They gave me the Jar file.
I imported the jar in MyEclipse. And it gave me some errors that some jars files are missing.I included those jars and the error was gone.In that way i find out the libraries for that batch program.I just want to know whether there will be any jar interdependencies?I mean some jars are required at the compile time and some jars are required at run time.?is there anything like that?Some jars wont be needed until we run the program?is that true?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30370
    
150

Originally posted by jaffrin abdul salam:
I mean some jars are required at the compile time and some jars are required at run time.?is there anything like that?Some jars wont be needed until we run the program?is that true?

Yes. The Jars that your program directly depends on are detectable at compile time. The jars that those jars depend on comes up at runtime.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
If you inherit from a class that is in another jar and that class inherits from a class in another jar your class would compile and yet fail at runtime. If you can test your program in its entirety it is the best way to know that you have all needed classes and this time have them document what is needed!


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
Turns out my previous comment was wrong. Last night I tried this and javac reported that a class was missing and would not compile my code.

Not sure if it matters, but I was comipiling with jdk 1.5.
[ August 23, 2007: Message edited by: steve souza ]
jaffrin abdul salam
Greenhorn

Joined: Sep 16, 2005
Posts: 23
If you inherit from a class that is in another jar and that class inherits from a class in another jar your class would compile and yet fail at runtime. If you can test your program in its entirety it is the best way to know that you have all needed classes and this time have them document what is needed!


Steve,Did you try the above one?That was my real doubt.
I thought Eclipse will be smart enough.It will find out all the libraries that are required.Because When i import the jar in eclipse,it will find out all the libraries that are required.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
<<If you inherit from a class that is in another jar and that class inherits from a class in another jar your class would compile and yet fail at runtime.>>
I did this and it failed at compile time, not runtime.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
And anything that you create by reflection - maybe Class.forName(name).newInstance() - will go undetected at compile time. You can compile JDBC programs with no drivers at all, but it's hard to run them that way.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jar interdependencies