Java Compilation error using Eclipse

Discussion in 'Java' started by Louis, Apr 6, 2004.

  1. Louis

    Louis Guest

    Hello,
    I am not a very skilled java programmer, in fact this is the first big
    java project I am compiling. It contains several .java file and a .jar
    library. I was able to compile the project with netBeans, opening the
    main .java file and doing a compile while the library is loaded
    correctly. But have never been able to run the applet with
    netbeans.(yeah BTW it s a java applet) So I wanted to try with
    eclipse, which seemed more appropriate since you can add different
    modules to it, with one particular i want to try for the performance
    analysis and such (hyades..).

    So here i go, I opened a new project. After many tries on different
    project building/settings options, I still cannot find the right
    options. The .java source file are in a subdirectory, like
    project/ver5/mdl/java/Prog/...
    and the library file is in project/ver5/...
    So with the best to perfect config, the errors I am getting now are
    all about one package:
    (Desc: The declared package does not match the expected package
    IN folder : project/mdl/java/Prog )

    Do i need to specify the source in a different way? there seems to be
    confusion finding the packages... =(

    Being a noob java programmer i dont know what info I should add.. so I
    hope someone can help me, I ve been stuck on this for a few days
    already!!!!!

    Thanks a bunch!

    Louis
     
    Louis, Apr 6, 2004
    #1
    1. Advertising

  2. Louis

    Chris Smith Guest

    Louis wrote:
    > So here i go, I opened a new project. After many tries on different
    > project building/settings options, I still cannot find the right
    > options. The .java source file are in a subdirectory, like
    > project/ver5/mdl/java/Prog/...
    > and the library file is in project/ver5/...
    > So with the best to perfect config, the errors I am getting now are
    > all about one package:
    > (Desc: The declared package does not match the expected package
    > IN folder : project/mdl/java/Prog )


    What is the 'package' declaration for a source file (any file) in the
    project/ver5/mdl/java/Prog directory? Or, if there isn't one, tell us
    that, too.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Apr 6, 2004
    #2
    1. Advertising

  3. > So here i go, I opened a new project. After many tries on different
    > project building/settings options, I still cannot find the right
    > options. The .java source file are in a subdirectory, like
    > project/ver5/mdl/java/Prog/...
    > and the library file is in project/ver5/...
    > So with the best to perfect config, the errors I am getting now are
    > all about one package:
    > (Desc: The declared package does not match the expected package
    > IN folder : project/mdl/java/Prog )
    >
    > Do i need to specify the source in a different way? there seems to be
    > confusion finding the packages... =(
    >
    > Being a noob java programmer i dont know what info I should add.. so I
    > hope someone can help me, I ve been stuck on this for a few days
    > already!!!!!
    >

    By default, Eclipse takes the project root directory as a source folder.
    So, subdirectories are seen as package elements, making it think your code
    is in a package project.mdl.java.Prog. This doesn't match the package
    declared *inside* the source file (presumably, your code is in the default
    package - no package declaration at all). Right click the project folder,
    open its properties and tell Eclipse the correct directory to use as the
    source folder. Under Java Build Path, you can specify which libraries your
    code needs.
    HTH,
    Michiel
     
    Michiel Konstapel, Apr 6, 2004
    #3
  4. Louis

    Louis Guest

    Michiel Konstapel <> wrote in message news:<>...
    > > So here i go, I opened a new project. After many tries on different
    > > project building/settings options, I still cannot find the right
    > > options. The .java source file are in a subdirectory, like
    > > project/ver5/mdl/java/Prog/...
    > > and the library file is in project/ver5/...
    > > So with the best to perfect config, the errors I am getting now are
    > > all about one package:
    > > (Desc: The declared package does not match the expected package
    > > IN folder : project/mdl/java/Prog )
    > >
    > > Do i need to specify the source in a different way? there seems to be
    > > confusion finding the packages... =(
    > >
    > > Being a noob java programmer i dont know what info I should add.. so I
    > > hope someone can help me, I ve been stuck on this for a few days
    > > already!!!!!
    > >

    > By default, Eclipse takes the project root directory as a source folder.
    > So, subdirectories are seen as package elements, making it think your code
    > is in a package project.mdl.java.Prog. This doesn't match the package
    > declared *inside* the source file (presumably, your code is in the default
    > package - no package declaration at all). Right click the project folder,
    > open its properties and tell Eclipse the correct directory to use as the
    > source folder. Under Java Build Path, you can specify which libraries your
    > code needs.
    > HTH,
    > Michiel



    I have been able to get no error message while compiling the
    project(only tons of warnings)... I see the package in the file tree
    (mdl.java.Welding2) but Eclipse doesnt seems to recognise it when I
    want to run the applet. When i go to Run... -> appelt -> new config.
    Eclipse doesnt find the applet class which should be
    (mdl.java.Welding2) ...
    what could be wrong now...?

    thanks again for your help!
    Louis
     
    Louis, Apr 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page