Exclude /WebContent/images folder from war in eclipse - eclipse

How can I configure eclipse in a way that the /images folder under /WebContent is not included in the war exported file ? I see how to exclude files and folders but under the /src container.

I'm not sure exactly why you'd want to do that, but here are two options:
Move your image folder OUT of WebContent (if you don't need them in the war, why are they here in the first place?)
In the project properties (Deployment Assembly tab, although that might vary with your version of Eclipse), remove the line telling eclipse to include WebContent in the war and individually add all other folders/files

Related

Automaticly add 3rd pary jars to Tomcat's lib folder

I'm using Eclipse Neon 4.6 and Tomcat 8. I have my deployment assembly set with external jars via user libs and dependent projects. When I clean and build the project only the dependent project's jar files are added to Tomcat's WEB-INF/lib folder, not the 3rd party external jars even though they are specified in user libs and the lib is in the deployment descriptor. Any ideas as to why Tomcat isn't automatically coping the user lib jar files? One interesting note is that if I put the jar files in the project's WEB-INF/lib folder they are not picked up at run time either. I have also tried adding WEB-INF/lib to the deployment descriptor without any luck.
So I figured this. Turns out I correctly had libraries as dependencies in the project but did not mark them for export in Project | properties | Java build path | Order and Export. I had to check the libs for export. Now they are included in the WEB-INF/lib folder when I create the project WAR file.

Exporting java projects in netbeans similar to eclipse

In eclipse, you can export a project as a jar file with the required libraries packaged in the same directory as the jar file in a separate folder. How exactly would I go about doing this in netbeans?
When using at. Right click on the project and select "Build" that will create a jar file in the dist directory of your project. If you have specified a main in your project that entry will be there in the manifest file, so you can easily use it a self-executing jar file.
All of the jar files that it depends on will be placed in the dist/lib directory of your project. If you are using your jar file as a self-executing jar file it is important that those files exist in a lib directory under the place where your jar file exists (i.e. their locations are recorded in the manifest file relative to the location of the jar). I know this is true when you use relative locations for your jars, but it may not be true if you've specified absolution locations.

Eclipse WebContent directory deployment in tomcat

In Eclipse, the folder structure when I create a Dynamic Web Project is
[srikanth#hana Sample]$ ls -R
.:
build src WebContent
./build:
classes
./build/classes:
./src:
./WebContent:
index.html META-INF scripts WEB-INF
./WebContent/META-INF:
MANIFEST.MF
./WebContent/scripts:
jquery-1.7.1.js
./WebContent/WEB-INF:
lib web.xml
./WebContent/WEB-INF/lib:
As you can see, there is this WebContent directory, When I copy the directory structure from Eclipse workspace and put in webapps directory of Tomcat, it didn't work. But, if I moved all the directories and files under WebContent directory a level above, it worked fine.
This is the folder structure in Tomcat's webapps directory under application:
[srikanth#hana Sample]$ ls -R
.:
build index.html META-INF scripts src WEB-INF
./build:
classes
./build/classes:
./META-INF:
MANIFEST.MF
./scripts:
jquery-1.7.1.js
./src:
./WEB-INF:
lib web.xml
./WEB-INF/lib:
So, now I can just go to http://localhost:8080/Sample and can go to index.html properly
What am I doing wrong? Why didn't it work just copying the application
from Eclipse to tomcat webapps directory directly? Why do I have to
change the directory structure?
I had the same problem, ./WebContent/index.html not appearing in the Eclipse-exported .war. This occurred on my new Eclipse system after I recreated a working project from my old system with Kepler Eclipse to a new system with Luna Eclipse.
I fixed this by going to Project / Properties / Deployment Assembly. I discovered that the old working system had this rule, while my new non-working systems was missing this rule ...
Source = /WebContent
Deploy Path = /
I corrected this on the new system by Pressing "Add..." and adding the missing rule.
Eclipse allows deploying the webapp directly to a server, without needing to copy anything by yourself. It also allows generating a deployable war file when you're ready to deploy to a test or production server.
Open the "Servers" view, right-click, and choose to create a new server. Once created, right-click on the server and choose to add your web-app into it. And then Eclipse will deploy your web-app to the server.
You're not supposed to manually copy anything from Eclipse. And if you need or want to do this, then you should probably use some ant script which generates the proper deployment structure. This structure is described in the servlet specification. It should have, under the root directory of the webapp, a WEB-INF directory containing:
classes: a directory containing your classes
lib: a directory containing all the jar files your app depends on
web.xml the webapp's deployment descriptor
All the other directories and files that are not under WEB-INF can be served by the web container.
When I copy the directory structure from Eclipse workspace and put in
webapps directory of Tomcat, it didn't work. But, if I moved all the
directories and files under WebContent directory a level above, it
worked fine
Not sure what you mean if I moved all the directories and files under WebContent directory a level above, it worked fine here and what you mean by saying a level above.
What you should be doing is not copy anything manually but right-click on the project and select Export as WAR option.
This will create a file named Project.war that contains the proper file structure i.e. WEB-INF etc that you are supposed to put under tomcat's webapps dir

How to create .classpath and .project files to make a project compatible with Eclipse Helios?

I am having a Java Web project with some class files, JSP files along with WEB-INF and META-INF folders. I want to use this project in Eclipse Helios.
For this I will need to import this project. However, Eclipse will search for .classpath and .project files in the root directory of the project. And unfortunately, I don't have these.
So, can I create one from the project?
Or do I just have to create one project and copy the files into the project? Though this will be a little tedious task if I have too many packages and class files.
Or do I just have to create one project and copy the files into the
project? Though this will be a little tedious task if I have too many
packages and class files.
It isn't tedious. Just create a blank Dynamic Web Project in Eclipse and copy the source folder. You can add a "Source Folder" to point to where your Java source files are present. It will then automatically add all the packages under it.

a way to mask/remove .svn directories from war exported from eclipse [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Ignore SVN files when exporting a WAR file from Eclipse?
Using eclipse + tomcat.
When I export a tomcat war file for my project, the war file contains all the .svn directories.
This is doubling the size of the war file and making deployments much longer than they need to be.
Is there a way to either mask these directories from the export mechanism (like a tar --exclude-from) or remove them from the war (tar --delete) ?
Go to the project properties > Resource > Resource Filters.
Add... > Exclude All > Files and Folders > All children (recursive) > name matches *.svn > OK.
All .svn files and folders will be ignored, including when you export war files.
Go to the project properties, Java Build Path, select the Source tab. For each source directory, there are Included: and Excluded: lines. Put a pattern into the exclusions (something like **/.svn).
What happens is that the builder copies anything that isn't a Java source file into the output folder as part of the build, unless it is in the exclusion list.
I usually build war's with ant even if I use Eclipse, have in mind that the svn specific directories is only part of it... you may find jar's you don't want in your application (shared JAR's for aexample) and ant has got a lot of fileset options to exclude files.