Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem with Eclipse - the declared package "" does not match the expected package

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with Eclipse - the declared package "" does not match the expected package

    Hello,
    I've been trying to learn Java with this tutorial Java Video Tutorial - YouTube 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.
    Last edited by SonGohan; August 5th, 2012 at 04:19 AM.


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Problem with Eclipse - the declared package "" does not match the expected pack

    You shouldn"t be creating a new file but a new class. If you tell the IDE you want a new class (HelloWorld in this case) it will create the correct souce file - HelloWorld.java - and put the correct package statement at the start.

Similar Threads

  1. finding "jar file name" by package name
    By nagaraj200788@gmail.com in forum Java Servlet
    Replies: 1
    Last Post: July 23rd, 2012, 11:13 AM
  2. Simple package problem, package does not exist error
    By Farmer in forum Object Oriented Programming
    Replies: 3
    Last Post: August 23rd, 2011, 11:18 AM
  3. Why the error said "few parameters expected 7" while i only have 6 fields?
    By Hafiz Mughni in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 9th, 2011, 10:45 AM
  4. "previously declared string"?... help
    By Taylorleemusic in forum Object Oriented Programming
    Replies: 3
    Last Post: September 15th, 2010, 10:57 PM
  5. "showMessageDialog" method in swing package
    By Delmi in forum Java Theory & Questions
    Replies: 1
    Last Post: May 13th, 2010, 02:52 PM