Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Getting There Packages

Jarvis Chandler
Jarvis Chandler
7,619 Points

Place the BlogPost.java file in the proper package by using the package keyword.

Let's create some code for the Example company. They own the domain example.com. Place the BlogPost.java file in the proper package by using the package keyword.

Having trouble with this, not sure were to start from?

com/example/BlogPost.java

Display.java
public class Display {
  public static void main(String[] args) {
    // Your code here...

  }
}

2 Answers

Priyesh Tungare
Priyesh Tungare
13,168 Points

Hi Jarvis,

As explained by Clayton, you need to have an package declaration in your BlogPost.java file with the domain name or the path where the common files related to your project are stored or placed (reversed order). Most of the companies use the reversed internet domain name in their package names like com.company.packageName

For example:

If my company's domain name is mytreehouse.sg.com, then I will use the package declaration as follows:

package com.sg.mytreehouse

So with respect to your question, the company has domain example.com. So you can use the package declaration as

package com.example

Thanks,

Priyesh T

Clayton Perszyk
MOD
Clayton Perszyk
Treehouse Moderator 48,850 Points

Hey Jarvis, In the file com/example/BlogPost.java you are going to place the reversed domain (i.e. com.example) on the first line, preceded by the keyword package; if you re-watch the video, Greg explains this step at about 1:54.

Hope this helps,

Clayton