Results 1 to 7 of 7
  1. #1
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Eclipse organization vs text file and folders?

    I am working though a couple of Java books and using both Eclipse and also just text editor with the java compiler. When I work with the text editor and the java compiler, I just have my files (.java and .class) in a folder stored by topic. The files are not linked together in any way, just stored in the same folder.
    When I use eclipse, I have a Project (one for each book) and then an src (whatever that is) under the project, and then I make a new package for each chapter, and then a new class where needed (for main or other classes.
    My questions are about the differences between these two types of program storage:
    - If I am using just the text editor and putting my classes into folders, what would I do to create packages, “src” (whatever that is), and projects?
    - Conversely, if I am using eclipse and I just want to make and run one standalone class (maybe a short swing program), do I still need to put it under a “Project, src, package” structure or can I just run it as a stand alone somehow?
    - Eclipse puts a "package" line at the top of each program that I really don't need for some standalone practice files, but if I delete it I get an error. How to run standalone programs that really don't need to link to a package?
    - What is that src? Do I really need to have it or can I just put my packages (even classes?) directly under the Project?
    Any comments comparing or relating these two class file organizations (text files kept in folders, or “Project, src, package” type organization is welcome.
    Thanks, drew

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Eclipse organization vs text file and folders?

    Eclipse manages 'resources' in a project for you; those resources are stored in files and Eclipse manages those files for you too, i.e. you don't even need to know about those files; the java sources are managed in a directory named 'src' and the generated class files are managed in a directory named 'bin' (the two directories can be merged when you create a project). Eclipse is much more than just a simple text editor and it uses a certain file/directory structure to be able to manage your resources.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Re: Eclipse organization vs text file and folders?

    Thank you very much for your reply. I checked out the "workspace", "src", and "bin" directories on my computer and saw what you were talking about. Very interesting.
    When I just write java programs in a text editor and compile them with the Javac command , then I just store all my files together in a single directory. Is there some reason that eclipse separates things into "workspace", "src", "bin" directories and such? Does that organization come into play later?
    Maybe it becomes important when I start to carry my code over to actually use somewhere? Up to now I am only running and testing my code on my PC, I never actually "used" the code anywhere.

    Maybe a related question. Does the eclipse organization have to follow Project;src;package;class? I mean, can I create a new class file right in the "src", not in a package? Or even can I create a new class file right in the Project (not under "src;package)? I guess I could just try that and see... but I am really curious when this special organization becomes important, and why I don't seem to have to use it when just writing with text editors.

    Thanks!

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Eclipse organization vs text file and folders?

    Quote Originally Posted by Drew345 View Post
    Is there some reason that eclipse separates things into "workspace", "src", "bin" directories and such? Does that organization come into play later?
    Well its not like you work on only one application ever in your life; or even one type of application. You will want a separate workspace per application. And applications generally won't be 2 source files either, organizing files is a rather important thing when your applications get bigger.

    I mean, can I create a new class file right in the "src", not in a package? Or even can I create a new class file right in the Project (not under "src;package)? I guess I could just try that and see... but I am really curious when this special organization becomes important, and why I don't seem to have to use it when just writing with text editors.

    Thanks!
    Yes you can (yes indeed rather than asking, just try it - its free and your computer does not melt), but there is no reason to want that. Use packages, Eclipse makes that effortless.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Eclipse organization vs text file and folders?

    Quote Originally Posted by gimbal2 View Post
    ... just try it - its free and your computer does not melt), ...
    Depands what you're trying :)
    https://community.oracle.com/thread/1363053

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Eclipse organization vs text file and folders?

    See, your computer didn't melt!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Eclipse organization vs text file and folders?

    It could have though!

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 09-28-2011, 07:30 PM
  2. File folders
    By lakshmibvaraprasad in forum New To Java
    Replies: 2
    Last Post: 08-09-2011, 07:56 PM
  3. Using a text file in Eclipse...I'm confused
    By raindog308 in forum Eclipse
    Replies: 1
    Last Post: 01-18-2011, 02:34 AM
  4. Configuring Java source folders for eclipse
    By kfir.wolfson@gmail.com in forum Eclipse
    Replies: 8
    Last Post: 10-01-2010, 12:11 PM
  5. Read text file with eclipse
    By Rohaan in forum Eclipse
    Replies: 9
    Last Post: 02-13-2010, 02:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •