Results 1 to 17 of 17
Like Tree1Likes
  • 1 Post By gimbal2

Thread: Confusion regarding classpath, src folder, bin folder.

  1. #1
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Confusion regarding classpath, src folder, bin folder.

    In the spring projects we have the xml file generally called Beans.xml. This file should be present in the classpath. Classpath is where the .class files are there. And the .class files are stored inside bin folder. Then why should the Beans.xml file be stored in src folder instead of bin folder?

    Help is appreciated.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Because most IDE's/build scripts, when you do a clean and build, will delete the contents of the bin directory.
    So that's why you don't store things in there.
    You store them in a src folder (which can be the 'src' folder, or another one, like 'resources') and have the build copy it over to the target (bin/jar/war/whatever).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Where do we mention that this file Beans.xml should be copied to the bin folder from src folder? Also is it necessary that the copy of the file needs to be created in the bin folder?
    Last edited by suhaas.mohandos@gmail.com; 08-02-2013 at 06:17 AM. Reason: Not complete

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    How are you building your project?
    If it's an IDE then it'll copy over non-java files in source directories.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Confusion regarding classpath, src folder, bin folder.

    I think you misunderstood what I asked.

    Let me try
    1. How come a copy of Beans.xml gets created automatically in bin folder?
    2. What is the problem if Beans.xml is in the src folder and the program can use it from there?

    I am using eclipse ide and running the program as Run as -> Java Application.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Actually, it may not copy it to the bin directory. I might be mixing in what it jars up with what it does in a basic compilation.

    You'll need to check that (easy enough).

    When executing in the IDE it's quite possible it simple uses the src directories.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Confusion regarding classpath, src folder, bin folder.

    I might be mixing in what it jars up with what it does in a basic compilation.
    Did not understand

    You'll need to check that (easy enough).
    Check what?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by suhaas.mohandos@gmail.com View Post
    I might be mixing in what it jars up with what it does in a basic compilation.
    Did not understand
    I might be wrong about what the IDE places in the bin folder during a compilation.
    When it creates a jar file (at least with Netbeans) it will take resources like your xml file and place it in the jar file.

    You'll need to check that (easy enough).
    Check what?
    Check whether it copies resources (like your xml file) into the bin directory.
    But in any case, if you have it in a source directory then it should pick it up.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by Tolls View Post
    ... if you have it in a source directory then it should pick it up.
    There's a setting for that.

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

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Is there?
    Been a while since I actually had to get Eclipse itself to do these things.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Confusion regarding classpath, src folder, bin folder.

    You set your build path in the project settings; this determines what your application is composed of. Here you define source directories and you can configure inclusions/exclusions and alternate target directories for compiled resources. Depending on the project type, sometimes you get really stupid defaults so you should always check if it is setup in a sane way.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by Tolls View Post
    Is there?
    Been a while since I actually had to get Eclipse itself to do these things.
    Oops, I missed that this was Eclipse.

    In NetBeans there's an 'exclude' (by default **/*.java,**/*.form) and any file with a name that isn't so excluded is copied over to the /build/classes tree.

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

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by gimbal2 View Post
    you can configure inclusions/exclusions and alternate target directories for compiled resources.
    So I guess it's much the same as in NetBeans. That's to be expected anyway.

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

  14. #14
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by gimbal2 View Post
    You set your build path in the project settings; this determines what your application is composed of. Here you define source directories and you can configure inclusions/exclusions and alternate target directories for compiled resources. Depending on the project type, sometimes you get really stupid defaults so you should always check if it is setup in a sane way.
    Too many opinions and confusions. Forget the settings part(if possible). Explain me why do tutorials says you should put the file Beans.xml in the classpath while it is actually placed in src folder, which is not the classpath?

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Confusion regarding classpath, src folder, bin folder.

    What tutorials?
    That's quite an important part because there is a difference between running something in an IDE, which will do things for you, and running something from the command line.

    In addition, you haven't said whether your IDE has actually copied the xml file from the src to the bin, which would answer your question pretty quickly.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  16. #16
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Confusion regarding classpath, src folder, bin folder.

    Quote Originally Posted by suhaas.mohandos@gmail.com View Post
    Too many opinions and confusions. Forget the settings part(if possible). Explain me why do tutorials says you should put the file Beans.xml in the classpath while it is actually placed in src folder, which is not the classpath?
    ... yes it is, everything in your sources ends up on the classpath. IF it is deployed properly.

    And tutorials are not to be followed blindly, they are to be understood and interpreted. They're not a "click here, click there" guide, they're a "research this, research that" guide. If you find a tutorial using Eclipse, that should trigger you to research how to properly use Eclipse, not go out of your way to avoid it.
    DarrylBurke likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  17. #17
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Confusion regarding classpath, src folder, bin folder.

    yes it is, everything in your sources ends up on the classpath. IF it is deployed properly.

    Thanks. That helped, but tell me one site which mentions "everything in your sources ends up on the classpath. IF it is deployed properly"

Similar Threads

  1. dist folder
    By mharsijamel in forum NetBeans
    Replies: 6
    Last Post: 01-10-2013, 05:05 PM
  2. Replies: 0
    Last Post: 10-28-2010, 01:46 PM
  3. Folder & Files
    By Prajin in forum Advanced Java
    Replies: 14
    Last Post: 07-14-2010, 11:31 AM
  4. Reading a .txt i a folder - help
    By Mattedatten in forum New To Java
    Replies: 6
    Last Post: 01-13-2010, 02:49 AM
  5. bin and lib folder
    By sdkanhere in forum New To Java
    Replies: 1
    Last Post: 10-07-2009, 05:46 PM

Posting Permissions

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