Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » the declared package "" does not match the expected package - SOLVED(Probably just simple problem)
the declared package "" does not match the expected package - SOLVED [message #900197] Sun, 05 August 2012 05:14 Go to next message
M M is currently offline M M
Messages: 1
Registered: August 2012
Junior Member
Hello,
I've been trying to learn Java with tutorial from youtube, but since i cant post link i can only sane that it is name "Java Video Tutorial" from user "derekbanas", but the problem I have with it is that when he started recording, he already had his eclipse set up and started project with file already in it.

Now everytime I try to do what he does, I get the error the declared package "" does not match the expected package.

This is what I do:

Start Eclipse, new workspace in Eclipse folder,E:\Eclipse\workspace File>New>Java Project enter>use default JRE (currently jre7),name "Test" press Finish

Expand Test>right click on src>New package>name package defaultPackage in source folder Test/src>Finish

Right click defaultPackage>New File>HelloWorld.java

Enter code>Ctrls+s to save BAM, declared package does not match the expected package.

What Am I doing wrong that I am getting the error?

Thanks for your time

SOLVED: Instead of creating new package, I just clicked on SRC and created new file, naming it HelloWorld and it created the default package by itself.

[Updated on: Sun, 05 August 2012 05:18]

Report message to a moderator

Re: =?UTF-8?B?dGhl77u/IGRlY2xhcmVkIHBhY2thZ2UgIiIgZG9lcyBub3QgbWE=?= [message #900204 is a reply to message #900197] Sun, 05 August 2012 09:58 Go to previous message
David Wegener is currently offline David Wegener
Messages: 1298
Registered: July 2009
Senior Member
On 08/05/2012 04:14 AM, M M wrote:
> Hello,
> I've been trying to learn Java with tutorial from youtube, but since i
> cant post link i can only sane that it is name "Java Video Tutorial"
> from user "derekbanas", but the problem I have with it is that when he
> started recording, he already had his eclipse set up and started project
> with file already in it.
>
> Now everytime I try to do what he does, I get the error the declared
> package "" does not match the expected package.
>
> This is what I do:
>
> Start Eclipse, new workspace in Eclipse folder,E:\Eclipse\workspace
> File>New>Java Project enter>use default JRE (currently jre7),name "Test"
> press Finish
>
> Expand Test>right click on src>New package>name package defaultPackage
> in source folder Test/src>Finish
>
> Right click defaultPackage>New File>HelloWorld.java
>
> Enter code>Ctrls+s to save BAM, declared package does not match the
> expected package.
>
> What Am I doing wrong that I am getting the error?
>
> Thanks for your time
The package statement at the top of your HelloWorld.java file has to
match the directory hierarchy from the src location on. You substitue /
for . in the package name to get the hierarchy.

A package com.test.myapp has to be in the directory hierarchy
com/test/myapp/
Previous Topic:Issue starting eclipse
Next Topic:Android Plugin not working
Goto Forum:
  


Current Time: Wed Apr 16 23:57:04 EDT 2014

Powered by FUDForum. Page generated in 0.06488 seconds