?
Solved

The Import

Posted on 2003-11-24
11
Medium Priority
?
321 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

800 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