How to simply create an Eclipse project and add some existing java source files ?

Discussion in 'Java' started by Gunter Hansen, Mar 30, 2006.

  1. I have developed some simple java classes (files) with some GUI elements. Nothing special.
    Up to this point I developed these classes by using the command line JDK v1.4.2

    Now I want to use Eclipse as development IDE for the further development.

    I installed successfully Eclipse and started it but then the questions start:

    I clicked menu File->New->Project and the wizard let me choose
    e.g. between "Java project", "Java"->"Java Project" and "Simple".
    Hey, what's the difference?

    Ok, I selected "Java Project" and clicked next, next, Finish.

    Now I wanted to add the previously created java sources outside of Eclipse.

    How do I do this?

    If I right click in the PackageExplorer on myProject and select "import" I cannot see
    a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
    or similar.
    If I move my old *.java files to the workspace folders they are not automatically included

    So again: How do I add external source files otherwise?

    Gunter
    Gunter Hansen, Mar 30, 2006
    #1
    1. Advertising

  2. Gunter Hansen

    Oliver Wong Guest

    "Gunter Hansen" <> wrote in message
    news:442c13ea$0$17571$-online.net...
    >I have developed some simple java classes (files) with some GUI elements.
    >Nothing special.
    > Up to this point I developed these classes by using the command line JDK
    > v1.4.2
    >
    > Now I want to use Eclipse as development IDE for the further development.
    >
    > I installed successfully Eclipse and started it but then the questions
    > start:
    >
    > I clicked menu File->New->Project and the wizard let me choose
    > e.g. between "Java project", "Java"->"Java Project" and "Simple".
    > Hey, what's the difference?
    >
    > Ok, I selected "Java Project" and clicked next, next, Finish.
    >
    > Now I wanted to add the previously created java sources outside of
    > Eclipse.
    >
    > How do I do this?
    >
    > If I right click in the PackageExplorer on myProject and select "import" I
    > cannot see
    > a "java source" entry. Alternatively I did not found a menu entry "add
    > external java sources"
    > or similar.
    > If I move my old *.java files to the workspace folders they are not
    > automatically included
    >
    > So again: How do I add external source files otherwise?


    After you've added your old *.java files to the workspace folder,
    refresh the project (there's a menu item to do this, or click on the
    project, then press F5). Your files should not be visible in the project. If
    not, post again, I'll try to give another solution.

    - Oliver
    Oliver Wong, Mar 30, 2006
    #2
    1. Advertising

  3. Gunter Hansen

    Guest

    After you moved the *.java files to the workspace did you do a refresh
    (right click on the package explorer to see the refresh option)? I was
    able to add java to a project this way.
    , Mar 30, 2006
    #3
  4. Gunter Hansen

    Chris Smith Guest

    Gunter Hansen <> wrote:
    > I clicked menu File->New->Project and the wizard let me choose
    > e.g. between "Java project", "Java"->"Java Project" and "Simple".
    > Hey, what's the difference?
    >
    > Ok, I selected "Java Project" and clicked next, next, Finish.
    >
    > Now I wanted to add the previously created java sources outside of Eclipse.
    >
    > How do I do this?


    In order for Eclipse to see a source file, it needs to reside in a
    source folder. If you created a project using a recent version of
    Eclipse and didn't change the defaults, then there is probably a
    directory in your project called "src". Put your source code there.
    Also, as Oliver said, right-click the project and choose "Refresh" after
    it's there.

    If you don't want to put your source code in the project, you can
    "link" the source code to the project instead. In that case, you should
    do the following:

    1. Right-click the project, and choose Properties from the context menu.
    2. Select "Java Build Path" from the left-hand side.
    3. Click the "Source" tab along the top.
    4. Click the "Link Source..." button.
    5. Fill out the dialog box, and click the OK buttons.

    That should create for you a sort of "virtual" source folder that really
    points elsewhere on your disk drive. For example, I've seen people do
    things this way in order to keep source code where Tomcat can find it in
    the webapps directory, but still develop it from Eclipse. I think
    that's a bad idea, and in fact I can't think of a good reason to use
    "Link Source", but it's there anyway if you want it.

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

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Mar 30, 2006
    #4
  5. Gunter Hansen

    Carl Guest

    Gunter Hansen wrote:
    > I have developed some simple java classes (files) with some GUI elements. Nothing special.
    > Up to this point I developed these classes by using the command line JDK v1.4.2
    >
    > Now I want to use Eclipse as development IDE for the further development.
    >
    > I installed successfully Eclipse and started it but then the questions start:
    >
    > I clicked menu File->New->Project and the wizard let me choose
    > e.g. between "Java project", "Java"->"Java Project" and "Simple".
    > Hey, what's the difference?
    >
    > Ok, I selected "Java Project" and clicked next, next, Finish.
    >
    > Now I wanted to add the previously created java sources outside of Eclipse.
    >
    > How do I do this?
    >
    > If I right click in the PackageExplorer on myProject and select "import" I cannot see
    > a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
    > or similar.
    > If I move my old *.java files to the workspace folders they are not automatically included
    >
    > So again: How do I add external source files otherwise?
    >
    > Gunter


    Gunter,

    In the package explorer, right click your new project and select
    import, then select the "File system" option. Here you should be
    presented with a dialog that allows you to browse for a directory.
    Select the base directory that contains you source files, and then
    check the files/directories you would like to import.

    Hope that helps,
    Carl.
    Carl, Mar 30, 2006
    #5
  6. Gunter Hansen

    Carl Guest

    Gunter Hansen wrote:
    > I have developed some simple java classes (files) with some GUI elements. Nothing special.
    > Up to this point I developed these classes by using the command line JDK v1.4.2
    >
    > Now I want to use Eclipse as development IDE for the further development.
    >
    > I installed successfully Eclipse and started it but then the questions start:
    >
    > I clicked menu File->New->Project and the wizard let me choose
    > e.g. between "Java project", "Java"->"Java Project" and "Simple".
    > Hey, what's the difference?
    >
    > Ok, I selected "Java Project" and clicked next, next, Finish.
    >
    > Now I wanted to add the previously created java sources outside of Eclipse.
    >
    > How do I do this?
    >
    > If I right click in the PackageExplorer on myProject and select "import" I cannot see
    > a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
    > or similar.
    > If I move my old *.java files to the workspace folders they are not automatically included
    >
    > So again: How do I add external source files otherwise?
    >
    > Gunter



    Gunter,

    >From the package explorer, right click your project and select import,

    then "File System", you should now be presented with a dialog where you
    can browse the file system. Here, open the base directory that contains
    your source files, then check the files/directories you would like to
    import. Review the options in the bottom checkbox group, and click
    finish.

    Hope that helps,
    Carl.
    Carl, Mar 30, 2006
    #6
  7. Hi,

    Getting started in Eclipse is notoriously tricky. You did it right so
    far, though. All you have to do to finish is right click your project
    and click 'Refresh'. This will refresh the project against the actual
    contents of the directory.

    'Simple', by the way, is a project that is just a directory. I.e., it
    won't be set up to build Java programs or anything like that.

    --
    Need to get from a Foo object to a Bar object in Java?
    Ask Prospector: http://snobol.cs.berkeley.edu
    Want to play tabletop RPGs over the internet?
    Check out Koboldsoft RPZen: http://www.koboldsoft.com
    Dave Mandelin, Mar 30, 2006
    #7
  8. file>import>file system>choose your files.
    Jordan T. Greenberg, Mar 30, 2006
    #8
  9. Gunter Hansen

    Carl Guest

    Gunter Hansen wrote:
    > I have developed some simple java classes (files) with some GUI elements. Nothing special.
    > Up to this point I developed these classes by using the command line JDK v1.4.2
    >
    > Now I want to use Eclipse as development IDE for the further development.
    >
    > I installed successfully Eclipse and started it but then the questions start:
    >
    > I clicked menu File->New->Project and the wizard let me choose
    > e.g. between "Java project", "Java"->"Java Project" and "Simple".
    > Hey, what's the difference?
    >
    > Ok, I selected "Java Project" and clicked next, next, Finish.
    >
    > Now I wanted to add the previously created java sources outside of Eclipse.
    >
    > How do I do this?
    >
    > If I right click in the PackageExplorer on myProject and select "import" I cannot see
    > a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
    > or similar.
    > If I move my old *.java files to the workspace folders they are not automatically included
    >
    > So again: How do I add external source files otherwise?
    >
    > Gunter


    Gunter,

    In the package explorer, right click your new project and select
    import, then select the "File system" option. Here you should be
    presented with a dialog that allows you to browse for a directory.
    Select the base directory that contains you source files, and then
    check the files/directories you would like to import.

    Hope that helps,
    Carl.
    Carl, Mar 30, 2006
    #9
  10. Gunter Hansen

    Paul Hamaker Guest

    If you choose 'import', then 'File system', you'll be able to select a
    folder and files to be copied to your project.
    Linking an existing source folder is a bit akward, goes like this :
    Right-click the project name,
    New, Folder
    Name it, Advanced
    Check link to folder in file system
    Browse to it
    Finish
    Wait, it's not over yet...
    Right-click project name,
    New, Source folder
    Same name as the folder you just made,
    Finish.
    I don't know if the last step is really necessary, but I do it anyway
    and it works for me.
    You might also take a look at my short guide to Eclipse :
    http://javalessons.com/eclipse/java-eclipse-1.html
    --------------------
    Paul Hamaker, SEMM, teaching ICT since 1987
    http://javalessons.com
    Paul Hamaker, Mar 30, 2006
    #10
  11. Gunter Hansen

    Paul Hamaker Guest

    Luckily, kicking myself is not that easy.
    Right-click the project name,
    Build path,
    Link additional source to project !!!!!!!!!!!!!!!

    Simple is right.
    --------------------
    Paul Hamaker, SEMM, teaching ICT since 1987
    http://javalessons.com
    Paul Hamaker, Apr 3, 2006
    #11
    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.
Similar Threads
  1. jai hanuman
    Replies:
    0
    Views:
    427
    jai hanuman
    Jun 15, 2004
  2. coollzh
    Replies:
    0
    Views:
    284
    coollzh
    May 18, 2004
  3. keperry
    Replies:
    3
    Views:
    5,582
    Venkatesh
    Apr 27, 2006
  4. Warren Tang
    Replies:
    13
    Views:
    12,988
  5. Deep Mehta via .NET 247
    Replies:
    2
    Views:
    403
    Dave A
    May 31, 2005
Loading...

Share This Page