Hi, I am new to Eclipse and I am trying to compile servlets in Eclipse and to automatically deploy it to Tomcat. I encountered following 3 questions. Can anybody help?
1. How to compile Servlets in Eclipse? If I click "Run", I was required to choose a configuration from JavaApplet to Eclipse Application. It seems not what I am looking for.
2. I downloaded the " Sysdeo Eclipse Tomcat Launcher plugin" for Eclipse 3.1, and have installed Tomcat 4.1.31. Set up Environment variables like "CATALINA_HOME" and "TOMCAT_HOME". However, after I open Java Perspective, go to Windows->Custom Perspective-> commands, I couldn't find "Available Command Groups", and therefore I can't enable "Tomcat" plug in. What's wrong?
3. How to make Eclipse automatically put the compiled classes into $TOMCAT_HOME/webapps/APPLICATION/WEB-INF/classes directory. I tried project->preference->Java Build Path->Order and Export. But the default output directory must be a location beneath the project.
MeiMei, 1) You compile a servlet the same way as any other Java class. (Project --> Rebuild or have Eclipse set to automatically recompile.) Just make sure you have j2ee.jar or servlets.jar in your classpath.
2) I don't know this one. Let's wait for someone who has used this plugin.
3) You can't compile to an external directory as you've noticed. You can manually copy the files or write an Ant file to do it automatically.
You need to RTFM sysdeo's installation instructions. When properly installed, you don't have to switch on anything. Just restart eclipse and the Tomcat icons appear on the toolbar (along with the Tomcat menu). The only fancy stuff you'd need is if you had existing webapp source you wanted to make available to be debugged, in which case you go to the Window/Preferences->Tomcat property editor.
You could build into TOMCAT_HOME/webapps/your_app_name directory, but I really don't recommend it. I keep a build/webapp directory in my project where I assemble everything (set the output class directory to build/webapp/WEB-INF-classes). Then I create a TOMCAT_HOME/conf/Catalina/localhost/your_app_name.xml file that defines the <Context> for that webapp. Which is the recommended way to do such things in Tomcat5. Editing server.xml and/or stuffing things in TOMCAT_HOME/webapps isn't really recommended. Especially editing server.xml.
Caveat: Tomcat 4 had the option of taking a WAR dropped into TOMCAT_HOME/webapps and exploding it. If the packages WAR was older than the exloded WAR files, nothing would be done. In Tomcat5, apparently all WARs are exploded, but they don't seem to be checking the relative ages (at least in Tomcat 5.0.28), so you have to manually remove the exploded WAR to get the updated stuff.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
posted 14 years ago
Thanks very much for all your kind replies.
To compile the servlet, I did go to "project->build all" to build the project, but I didn't see the class file in the output "classes" directory. Currently, in the "Java BuildPath" dialog, the default output folder is set to PROJECT_NAME/classes. And here are the files under the project "HelloWorld" and the content in the ".classpath" file that resides under the project directory.
D:/eclipse/workspace1/HelloWorld>ls -a . .classpath HelloWorldServlet.java .. .project classes
Thanks for your help. Now I did get servlets automatically compiled in Eclipse, but still having trouble integrating the Tomcat plugin with Eclipse.
After I downloaded and unzipped the "Sysdeo Eclipse Tomcat Launcher plugin" into my Eclipse/plugin directory, I did see "com.sysdeo.eclipse.tomcat_3.1.0" exisiting in the plugin directory. However, there is no "tomcat" icon appearing in the toolbar, neither a "Tomcat" list under "Window->prefernce->customer perspective...->commands->Available command groups". Actually, I can't find "Avaiable command groups" in "comands" dialog.
Your help will be greatly appreciated.
posted 14 years ago
To correct an error in my previous reply, I can't find "Available command groups" under "Window->customer perspective...->commands" instead of "Window->prefernce->customer perspective...->commands->Available command groups".
New rule: no elephants at the chess tournament. Tiny ads are still okay.