This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing javax.servlet.* and javax.servlet.http using Eclipse in Ubuntu

 
pakske fritten
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im a beginner who just finished head first Java. I need to install the servlets jar but don't know exactly how. I am using eclipse on ubuntu and have tomcat installed. Currently eclipse does not know how to import javax.servlet.*


1)where do I find servet.jar
2)do I manually download it and then copy it in some folder? Or do I import it in the IDE eclipse?
3) what does tomcat have to do with this; I read everywhere I need . I installed tomcat 6.


Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pakske fritten wrote:
1)where do I find servet.jar

In Tomcat's lib folder. And it's not "servet.jar" (please proofread your posts), it's servlet-api.jar.

2)do I manually download it and then copy it in some folder? Or do I import it in the IDE eclipse?

If you've downloaded Tomcat, you already have it. You need to configure eclipse to find it. (Don't ask me how; I don't use eclipse.)

3) what does tomcat have to do with this; I read everywhere I need . I installed tomcat 6.

How do you expect to run your servlets without a servlet engine?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, make sure that downloaded the Eclipse package named "Eclipse IDE for Java EE Developers".

Second, in Eclipse you need to create two things. The first is a Server, and the other is a Dynamic Wen App project. This tutorial might help with the details:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:First, make sure that downloaded the Eclipse package named "Eclipse IDE for Java EE Developers".

Second, in Eclipse you need to create two things. The first is a Server, and the other is a Dynamic Wen App project. This tutorial might help with the details:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html


Only if you enjoy gouging out your own eyeballs. There are better ways. I recommend the sysdeo Tomcat plugin, myself.

Regardless of whether you use the unspeakably vile built-in WTP plugin or some other plugin such as sysdeo, however, you must have a copy of Tomcat installed on your Ubuntu machine somewhere. Exactly where isn't important as long as you can run Tomcat.

The easiest way to make the servlet APIs visible to the compiler for an Eclipse project is to a library of jars so that the servlet and jsp API jars are symbolically (and portably) referenceable by all projects in the workspace. You can do this by:

1. selecting a Java project and opening its properties dialog to the build path page.
2. On the Java Build Path page, select the Libraries tab.
3. Click the Add Library button
4. Select User Library/Next.
5. Click the "User Libraries..." button.
6. Click "New" to create a new User Library. Give it a name (I use "TOMCAT", but "J2EE" is a good choice, too).
7. Click the "Add Jars" button to add jars to this library definition. Add the jsp-api.jar and servlet-api.jars from your installed Tomcat's lib directory.

Done! You can now save this definition, add it to your project by checking the checkbox on Add Library/User Library/Next/User Libraries...", and do likewise for any other webapp projects you have.
 
pakske fritten
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect response.
I found the servlet-api.jar and jsp-api.jar files in /usr/share/tomcat6/lib and added it and now ECLIPSE recognizes the javax.servlet.* .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic