?
Solved

The Import

Posted on 2003-11-24
11
Medium Priority
?
324 Views
Last Modified: 2010-04-01
I have observed the following

import  com.bruceeckel.simpletest.*;

I would like to know why is the above statement so structured? Would like as much details as possible.

Thanks and Regards,


ananda
0
Comment
Question by:a_tirtha
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9809582
http://mindprod.com/jgloss/import.html#IMPORT

Though that's java... in a JSP, it is:

<%@ page import="com.bruceeckel.simpletest.*" %>

Basically, it's telling the compiler you use classes in the com.bruceeckel.simpletest package...

Tim
0
 

Author Comment

by:a_tirtha
ID: 9809734
why this paggern "com.bruceeckel.simpletest" ?
0
 

Author Comment

by:a_tirtha
ID: 9809736
Correction
why this pattern "com.bruceeckel.simpletest" ?

Excuse for typographical mistake
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 35

Expert Comment

by:TimYates
ID: 9809748
that's packages...

import java.awt.* ;

means "I'm going to be using classes inside the java.awt package"

import  com.bruceeckel.simpletest.* ;

means "I'm going to be using classes inside the com.bruceeckel.simpletest package"

This package is part of the book "Thinking in Java", by Bruce Eckel;

http://www.mindview.net/Books/TIJ/
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9809752
0
 
LVL 1

Expert Comment

by:deepak_a
ID: 9815874
Simply put,
 "com.bruceeckel.simpletest " means
com is a folder inside which there is another folder called bruceeckel. Inside bruceeckel folder is ur java class called simpletest.
 So it is like u r telling ur compiler to go into the directory com then the subdirectory bruceeckel where the compiler will find the class simpletest.
 If instead of simpletest u specify *, u r telling the compiler to use all the files in com.bruceeckel.
0
 

Author Comment

by:a_tirtha
ID: 9815945
The comments so give me an idea that the statement is defined to access a package. It is really clear upto this poing.

Now!.  Simpletest is package that is a part of www.bruceeckel.com. Right!!!

Now someone please tell me the purpose/logic behind defining the statement as

import com.bruceeckel.simpletest.*;  

why is the web url referred with the "com" in the begining , followed by the "." and "Bruceeckle.packagename...."?  

0
 
LVL 1

Expert Comment

by:deepak_a
ID: 9816042
The package name import has got nothing to do with the web url. They are 2 totally different things and not related to each other at all.
The package name can be sumething like.
deepak.acharya.analyst.*;
Totally legal.
Generally in real life projects they do mention packages like com. this.that;
com stands for commerical/commerce.

But note. the package
com.bruceeckel.simpletest.*;   is in no way related to www.bruceeckel.com

www.bruceeckel.com is a website
and com.bruceeckel.simpletest.*; is a folder. The two are totally unrelated.
0
 
LVL 15

Accepted Solution

by:
jimmack earned 100 total points
ID: 9819148
I think the explanation you are looking for is as follows:

When packaging your Java code, you want to avoid having the same package names as anyone else (ie. your own package names should be unique).

The standard, easiest (and usually most reliable) way to achieve this is to use your own domain name, since no-one else should be using the same text in their package names.  Generally, the domain name is reversed because the importance of the domain elements reads from right to left (.com is the most significant part, bruceeckel is the next most significant etc., but you don't need to go all the way to "www" ;-)).


Some corrections/clarifications:

>> But note. the package
>> com.bruceeckel.simpletest.*;   is in no way related to www.bruceeckel.com

This isn't strictly speaking correct.  The two *are* related by the fact that Bruce Eckel (a very good author ;-)) relies on the fact that no-one else is going to be using his domain name for their package names.

>> and com.bruceeckel.simpletest.*; is a folder. The two are totally unrelated.
This is not a folder.  It is a package reference.  It just so happens that when you compile the code (with the -d option), the folders will be created to "mirror" the package reference.  Ideally, your source code tree (your .java files) should also mirror the target tree (where your .class files go), but this isn't *required*, just easier to maintain and understand ;-)
0
 

Author Comment

by:a_tirtha
ID: 9829491
Hello Jimmack,

Thanks a lot for you comments. It is of immence help and clarity.

Thanks again,

Ananda
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9830536
;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 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