views:

51

answers:

2

I am starting out with Google's App Engine in Java. I have seen the tutorial video but I do not understand the naming of the project package.

It is going to be a guestbook, that's why the name is guestbook, I understand that part. But after that I see package name. 1)Is that something you import into the project, or is is something you create.

I have seen this a lot in projects, something like com.xxx.xxx. 2)How do you name this type of thing or is this an import.

I have looked at another tutorial there they take the naming to a whole new level. The name of both the project and the package is de.vogella.gae.java.todo. 3)What does this mean in java terms.

4)Maybe one of you can help me with this specific project I want to start. I want to create a Google App project that for now only serves static files. I will leave the project empty and just put all my static files in the war directory of the project. I want the domain name to be mydomainstatic

+3  A: 

1 & 2) Package name is actually the com.xxx.xxx thing you have already seen in other projects. It provides a namespace so that you don't collide with the naming scheme used by other applications.

The namespace is also the directory structure that the source files follow. com.xxx.xxx would have its files as src/com/xxx/xxx/Classname.java

The most common use for a package is in import lines to make Java look in specific packages for code files. import com.xxx.xxx.*; would allow you to use anything directly in com.xxx.xxx (but not com.xxx.xxx.yyy) without giving the entire package name every time.

Generally, the package name is an reversed domain name, followed by a project name.

For example, if StackOverflow had a Guestbook written in Java, it could have the package com.stackoverflow.guestbook.

3) de is the top level domain (TLD) for Germany (Deutschland). Their package name breaks down to: TLD.domain name.Google App Engine.language (Java).Project Name

4) Really the naming style is up to you. If you went by the tutorials' style, it would be com.mydomainstatic.gae.java.project Personally, I think the java level is redundant, although the gae level could be useful information.

R. Bemrose
Thank you for pointing this out. You explained it quite well. So this has nothing to do with importing stuff. It is a way of naming stuff.
Saif Bechan
A: 

It sounds like you lack the basic understanding of what a Java package is. There's an official tutorial that may be able to help you. Read up on it, we've all got to start somewhere =)

It's likely the GAE documents will make much more sense once you've got packages figured out.

Packages are the fundamental way of uniquely identifying a class. If you create a Guestbook class, and I create a Guestbook class as well, how do you refer to both within a single project?

Packages allow you to call yours "com.yourdomain.Guestbook" while mine may be "com.mydomain.Guestbook". While they also allow for more fine-tuned method/member access, the global namespace is key.

Jason Nichols
Thank you I will read trough. I have basic knowledge of java packaged, but not in web development. I used packages in normal Java applications.
Saif Bechan