Add jar source to main project - eclipse

In my workspace, I have my main project and it uses several jars. I need to make changes in one of the jars. I added the source for that jar to my workspace and I make the change, create a new jar at the command line, copy it over to my main project, bounce app server and try it out. Is there a way to instead point my project at the jar source rather than the jar file? I'd expect to change the jar source, Eclipse would auto build like it does my main project, and I'd only have to restart my app server to test.

You can add external jars, then you can build the jar, safe it somewhere accessible by your app server and restart the server, it will use the new jar and everything should be fine.
For a bigger scope there are many solutions using maven for example to build more then one Project at a time and merge them like needed, but that would be to much for a single jar.

Related

gwt images external to WAR file

I am working with GWT and I have some issues with the images. I need images outside my WAR file and, In order to make them visible in the application, I must put them inside the "target" folder ( I am using maven as well). The problem is that the target folder by definition is deleted every time recompile the project. This issue happens only in hosted mode, because when I deploy the application on Tomcat I can just change the server.xml adding the following statement
and it should read correctly images outside my WAR file(not tried yet due to another problem I have)
Can anybody give me some suggestions?
What is the directory structure of your maven project? Why is there a requirement for you to put the images in the target folder? Typically in a Maven project the items you put in the src/main/resources/static such as images end up in the built artifact.

Does the buildpath needs to reconfigured on local machine for a project checked-out through SVN?

This is my first time using SVN or for that matter any version control. So, I've been able to check out a selenium project on my local machine. This source code was working fine on the other machine(my friend's), but on my machine it throws hundreds of errors such as "BeforeClass cannot be resolved to a type, Assert cannot be resolved to a type" etc.
I do know that this error could be because the required selenium jars may not have been setup in the build path. But, I can see all these selenium jars in the "lib" folder.
So, I want to understand if I need to reconfigure the build path. By the way, don't the project settings etc come by default as the same code works perfectly on other machine, which means the build path must have been configured there.
I know its a very basic question, but I assure you that I'm a naive coder.
Thanks for your help.
Note: I'm using Eclipse IDE
Eclipse's project configuration files (eg, .project, .classpath, .settings, etc) are designed to be checked in with the rest of the project. If done so, whenever the project is checked out to a workspace Eclipse will automatically use them to properly configure the project. Check that your friend checked in those files; if not, ask him to.
It looks like you did not add Eclipse project metadata files(.project,.classpath) & .settings folder to your source control system, so Eclipse doesn't know what your build path is or whether it is even a java project.
Go back to your other computer and look for the following files in your original project root...
.project
.classpath
.settings/*
Make sure all are present in Source Control System.

Adding project dependency to web project in Eclipse

I have a Dynamic Web Project that gets deployed as a WAR that I have created in Eclipse. The project depends on 2 other small projects. I have them marked for export, and have them on the build path, but Eclipse warns me that it will not be exported, and sure enough, I get a ClassNotFoundException when I try to compile.
If need be, I can pull all the java files into a .zip file, but I don't know how to add a .zip file as a dependency. I'm sure I'm making this harder than it needs to be.
Open the web project's Properties dialog (context menu, or Project menu from the menu bar) and go to the Deployment Assembly page. This is where you tell it to also make them jars when deploying.

Adding jars to Tomcat classpath

I have an Eclipse project running on Tomcat, with my dependency jars sitting in the WEB-INF/lib directory. Everything is great. But the war file created on export is huge, and I'm going to need to send it back and forth to the test server, which will be time consuming. It seems like a waste.
So I put all my dependency jars in a folder, dependency_jars, in my file system, and configured the build to point there. The build works, but when I run it (still on my local machine) the app is throwing runtime errors.
Reading around, I went to the project properties and added the jars to the Web Deployment Assembly. Now the runtime works, but the exported war once again has all the jars packaged with it.
So how do I have my dependencies available for the runtime environment, without having Eclipse package them inside the war?
OK I'm not sure this is the most elegant solution but what I did is configure Tomcat to use an external library, put the dependency jars there, and then let eclipse create the war with everything in it, explode it from the command line, remove the dependency jars, repackage the war, and finally send it out.
Well, definitely not an elegant solution. But it works. Here are the steps:
Configure Tomcat to use an external resources library. Go to tomcat_home/conf/catalina.properties and add your directory under the comment that starts with "List of comma-separated paths defining the contents of the "common" classloader..."
Export war through Eclipse.
Explode the war (pun probably merited here:) jar -xvf MyWar.war
Remove your dependency jars (which are now in the external directory from step 1 above.)
Repackage the war: jar cvf MyWar.war WEB-INF

JAR File is Viewed as Folder

I have a JAR-file in the WEB-INF/lib directory of my project that is displayed as folder when I deploy my project to Tomcat.
I use Maven for getting JAR-files, Eclipse for building my app, and deploying to Tomcat.
Why is the JAR-file displayed as folder? I cannot use the file in this way, and Tomcat does not see it.
This settings is for any child module if we have one parent maven project for him and we want to use wtp.
Eclipse gets changes from workspace.
For Example, we make changes in maven module and we don't need to install it and update dependencies for parent. Eclipse automatically updates the changes.
Because if you use Eclipse Web Tools Platform for deploying, it puts artifacts, that you have in your Eclipse workspace as projects, exploded. It allows WTP to do some magic with replacing classes files in-place instead of repackaging whole artifact on every little change. For the container, it really doesn't matter.