I am trying to run an existing eclipse project created by another person.
After importing it into eclipse and trying to run As-> Java Application, it fails because it cannot find the .properties file in bin / resources
I printed the eclipse classpath using
logger.info(System.getProperty("java.class.path"));
and of course, it includes bin and all lib / *. jars but not bin / resources. Copying the .properties file to bin does the work of the program, but I would like to understand how to add the directory to the eclipse class path.
I tried a few things, none of which worked
export CLASSPATH=$CLASSPATH:/home/me/programdir/bin/resources
This did not work. I understand that this is not a desirable way to approach the problem, but I thought it would fix the problem (I have more windows than the linux background, so maybe I miss some of the nuances of system variables in Linux)
The next time I tried changing the arguments of a virtual machine in the Run-> Configurations dialog in Eclipse
-classpath "/home/me/programdir/bin/resources"
I was also unlucky that I was confused, since I was sure that this would work and seems like a reasonable solution for a specific program that requires an additional folder added to the classpath.
Next, I tried to modify build.xml directly. I found the part that defines the classpath and added my own line for bin / resources, as follows:
<path id="classpath"> <fileset dir="./bin/resources" includes="**/*.properties"/> <fileset dir="./lib" includes="**/*.jar" /> </path>
This, too, was unsuccessful. This puzzled me even more, so I commented on the whole path element, and the class path printed by the log remained unchanged, so it is obvious that any use of eclipse in the class, of course, was not that. It seemed to me the best solution if it worked: the build.xml file could be checked with the right add-ons to prevent future users from running into a problem.
Next, I tried to apply the IDE approach. Run-> Configurations-> Classpath-> User Entries-> Advanced and just added the bin / resources folder. This worked perfectly, the program finds the properties file, everything is in order. However, I am unhappy that my previous efforts failed, and I did not understand why. It seems that each of them should have worked.
In addition, I want me to fix this problem so that it is fixed by the code that I check so that subsequent users do not have to go through the same steps. My solution, therefore, is not very satisfactory, since I am not sure that I changed the actual code fragment and therefore cannot check if the "fix" is checked.
How do you find the actual definition that eclipse uses for its classpath? I thought this would be the classpath definition for build.xml, but it seems like this is not at all.