Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

The Import

Posted on 2003-11-24
11
Medium Priority
?
322 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 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