Solved

import confusion!!

Posted on 2006-06-28
12
396 Views
Last Modified: 2012-06-21
for example.. I have two .jar files in my ext. jdom.jar and eva3rt.jar
when i do import org.jdom.*, which one will be imported, because both jar contents org.jdom.

similar confusion when i use implements provided by third party. for example jtapi.jar gives APIs and Xtapi.jar gives its implementation. but in our application we use the APIs. So how this mapping takes place...
 .. infact I'm even confused with my this query.. so anyone can provide me a link from where I can understand these stuffs.

Thanks in Advance..

0
Comment
Question by:RupeshB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +5
12 Comments
 
LVL 23

Assisted Solution

by:Ajay-Singh
Ajay-Singh earned 100 total points
ID: 17007113
The discovery of classes is done sequencely as the jar appears in the classpath.
0
 

Author Comment

by:RupeshB
ID: 17007120
then how to change orders of jars
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17007215
like this

set CLASSPATH=jdom.jar;eva3rt.jar;.
or
set CLASSPATH=eva3rt.jar;jdom.jar;.

whichever comes first, has priority over the other
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:RupeshB
ID: 17007298
that's ok but not effective way... still waiting for full answer...
0
 
LVL 35

Expert Comment

by:girionis
ID: 17007356
If you put them in the /ext folder I think it will be done alphabetically. If you want different order you will have to take them out of /ext and put them in your user-defined classpath.
0
 
LVL 8

Expert Comment

by:colr__
ID: 17007567
To avoid any amibiguity you should use the fully qualified name of your class in the import. This makes your code easier to read, maintain, and removes any ambiguity.

colr__
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 17007765
right, but the question is about same package in diferent jars
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 17007787
If you are using eclipse you can specify the jars for each project,

do you need both these jars in the same project??

if two jars have same package and are in the same project then the behaviour  might not be as you expected.

so wat you can do is seperate your aplication into two projects. in one project add the first jar
and in the second one the second jar. split your apllication based on that. later you can combine both of them using a third project or may be in anyone of the projects
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17007843
> that's ok but not effective way... still waiting for full answer...

I think you're looking for a little magic - it doesn't exist. The reality is that if you have conflicts in your jars, that's your problem, and you should probably fix that before you worry about the order in which they're loaded (which is, as explained above, the order in which they're "seen" by the JVM).
0
 
LVL 8

Expert Comment

by:colr__
ID: 17007847
mukundha_expert  > your right, I was assuming that the package names just happened to be the same (in which case the class names would be differnet maybe), not that they were actually the same package.
0
 
LVL 13

Accepted Solution

by:
Webstorm earned 150 total points
ID: 17008348
If you want to use both classes, you can try to use 2 different class loaders, and use the one containing the package you want to use.


>> similar confusion when i use implements provided by third party. for example jtapi.jar gives APIs and Xtapi.jar gives its implementation. but in our application we use the APIs. So how this mapping takes place...

The API may have something to know which classes implement it. It may be a configuration file containing fully-qualified class names, or you have to explicitly give this class name when you call the API.
Or you have to direclty use the implementation classes.
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17009121
Typically the APIs contain abstract base classes and the implementation jar contains the concrete implementations of these. It depends on whether you're calling the functionality (use the implementation jar) or implementing it yourself (use the API jar).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
web application structure 18 117
String array comparison 4 46
Java: The Public Class Main 4 46
web project error add remove 1 56
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question