a little thing which is bothering me for awhile when writing some little java programs to try out some stuff.
I have my project dir in the Eclipse package explorer along with the /src package, along with a /lib and a /resources folder.
Now when i let eclipse run/debug my program and all my relative locations to those dirs are not found since eclipse creats a /bin directory but does not copy my folders.
Can i somehow instruct eclipse to copy my folders into the bin folder?
You could add the folders you would like to have copied into the bin folder to the source folders.
Right click on your project and choose Properties.
Select Java build Path on the left, and click the Source tab.
That should look something like this:
Click Add Folder... to add your /lib and /resource folders.
Related
The program runs as it should in eclipse, however when I try running it as a Jar it throws a noClassDefFoundError.
I assume this is due to an imported jar (commons-io-2.4.jar) that does not get added to the classpath. Apparently I only need to add this jar to the lib folder. Problem is, I can't find this folder (in the workspace there are only .setting, bin and src, as well as a .classpath and a .project file) and I haven't found any options in the Projects properties that would solve this problem.
How do I do this in eclipse?
Add the jar in source dir or project folder then select in eclipse, right-click will give you to add the jar in classpath
I checked out a project from svn. The project have a folder named as "ws" which contains WebContent folder. But the lib folder is outside the WebContent folder and under another folder under "ws" folder. I found out I have to move the lib folder to WEB-INF folder in WebContent folder, so eclipse can find the libraries I need.
Would anyone show me how to manually set the path so eclipse can load the libraries from the original lib without moving the lib to WEB-INF?
Thanks
You can edit the Deployment Assembly which controls how the app deployment is assembled. Right-click the project and select Properties; select Deployment Assembly and then use Add... to include your project's libraries (JARs) in the deployed WEB-INF/lib folder.
If you've already included the libraries on the project Build Path, there's an option in the Add... dialog to include them directly. Otherwise you can just add a folder itself.
I'm trying to export a project as a .jar in NetBeans 8, and I realize it's supposed to save automatically. All the sources I've found point out that it should be located in <myProjectFolder>/dist,but that directory does not exist-- is there a setting I must toggle?
You have to first clean and build to generate one.
As you do programming work you will see the result of your work , but this doesn't go into the dist folder until you clean and build.
Right click your project name in the NetBeans and you will see many options
starting with new, Build, clean and Build. click the clean and build and it will
create a dist folder which has the war file and you can access the dist folder
in the files at the top (projects Files Services)
I am now doing a project using Eclipse, and I have some resource files (e.g., image, text) saved in the bin folder, and these files are needed by the program.
However, with every build, Eclipse would try to clean up the folder, then rebuild the project. When cleaning, it deletes the resource files in the folder. Is there anyway to stop Eclipse from doing this?
I know I could change the location of the files, but I am also curious why Eclipse would do this, and could this be prevented from happening.
Thanks!
Go to Options -> Java-> Compiler -> Building and uncheck Scrub output folders when cleaning projects.
That did the trick for me. In my project, I have an Ant task that adds a few configuration resources to the bin folder to include them in the classpath, without having them in src
I can't say exactly why it does it, but probably that's just how Eclipse does the build: empty the "output folder" and start compiling.
That said, if you put your files into a source folder, then Eclipse will simply copy the files over to bin on every build and they won't disappear. It will do this to any file it doesn't know how to compile, e.g. .xml, .xsd, .png, etc.
You can consider using a maven style project and add the resources to the resources folder.
Here is a link to maven directory layout.
What kind of project you are using in eclipse. You can turn off build automatically feature in the Project menu. Which would stop eclipse from cleaning up projects automatically.
Copy and paste your resources into the source folder. In eclipse, in package explorer, find your project, then paste into src. It then gives an option to copy the file or link to it. Click copy and it gets stored in /bin but won't get deleted.
Motivation
In eclipse I'd like to configure a path as a resource path. This path contains some java files that I only want to handle as resources, i.e. I don't want eclipse to try to compile these files. I only want to read them as resources from within junit tests.
Question
Is there a way to configure eclipse so it won't try to compile the java files it found there?
You can specify excludes for *.java files in project properties / Build Path / Sources preferences. However in that case *.java won't be copied into the target folder, so those resources won't be available at runtime classpath. To get around that, after adding excludes you can add a custom builder (e.g. Ant script) that would copy *.java files over.
Alternatively, you can use m2eclipse with Maven-enabled project and place your java files into src/main/resources, so all files from that folder won't be compiled, but they will be copied into the result classpath.
Also, you can try to point target folder to the same dir as source folder.
You can remove the folder from build-path:
Right click on project -> Build Path -> Configure Build Path
Select tab "Source"
Remove the folder you want only to handle as resources
Eclipse won't compile Java files in that folder
Check Included=All and Excluded=**/*.java for the specific source folder in the Java Build Path through the Project properties.
alt text http://img708.imageshack.us/img708/3509/eclipseexclusion.png