the declared package "" does not match the expected package - SOLVED [message #900197] |
Sun, 05 August 2012 09:14 |
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 09:18] Report message to a moderator
|
|
|
Re: =?UTF-8?B?dGhl77u/IGRlY2xhcmVkIHBhY2thZ2UgIiIgZG9lcyBub3QgbWE=?= [message #900204 is a reply to message #900197] |
Sun, 05 August 2012 13:58 |
David Wegener Messages: 1445 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/
|
|
|
Powered by
FUDForum. Page generated in 0.08208 seconds