How to place a file on classpath in Eclipse?

EclipseClasspath

Eclipse Problem Overview


As this documentation says, "For example if you place this jndi.properties file on your classpath", but how can I place the .properties file on my classpath if I am using Eclipse?

Eclipse Solutions


Solution 1 - Eclipse

Just to add. If you right-click on an eclipse project and select Properties, select the Java Build Path link on the left. Then select the Source Tab. You'll see a list of all the java source folders. You can even add your own. By default the {project}/src folder is the classpath folder.

Solution 2 - Eclipse

One option is to place your properties file in the src/ directory of your project. This will copy it to the "classes" (along with your .class files) at build time. I often do this for web projects.

Solution 3 - Eclipse

This might not be the most useful answer, more of an addendum, but the above answer (from greenkode) confused me for all of 10 seconds.

"Add Folder" only lets you see folders that are the sub-folders of the project whose build path you are looking at.

The "Link Source" button in the above image would be called "Add External Folder" in an ideal world.

I had to make a properties file that is to be shared between multiple projects, and by keeping the properties file in an external folder, I am able to have only one, instead of having a copy in each project.

Solution 4 - Eclipse

Well one of the option is to goto your workspace, your project folder, then bin copy and paste the log4j properites file. it would be better to paste the file also in source folder.

Now you may want to know from where to get this file, download smslib, then extract it, then smslib->misc->log4j sample configuration -> log4j here you go.

This what helped,me so just wanted to know.

Solution 5 - Eclipse

Copy the file into your src folder. Go to the Project Explorer in Eclipse, Right-click on your project, and click on "Refresh". The file should appear on the Project Explorer pane as well.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCacheingView Question on Stackoverflow
Solution 1 - EclipsegreenkodeView Answer on Stackoverflow
Solution 2 - Eclipsepaulsm4View Answer on Stackoverflow
Solution 3 - Eclipsejustian17View Answer on Stackoverflow
Solution 4 - EclipseanzalaView Answer on Stackoverflow
Solution 5 - EclipseBatwoman05View Answer on Stackoverflow