简体   繁体   中英

Setting up Tomcat in Eclipse on Ubuntu

I'm trying to setup Tomcat in Eclipse. I've already followed this tutorial on how to install Tomcat and I'm even able to see the default Tomcat page at localhost:8080 .

What I need now is to setup Tomcat on Eclipse.

I do the following:

Window->Preferences->Server->Runtime Environment->Add->"Apache Tomcat v8.5"

As Tomcat's installation directory I enter /opt/tomcat , as specified in the tutorial linked above in Step 3: Install Tomcat :

We will install Tomcat to the /opt/tomcat directory. Create the directory, then extract the archive to it [...]

But I get the following error:

Unknown version of Tomcat was specified.

As can be seen here:

在此处输入图片说明

Some more infos:

  • Tomcat 8.5.20
  • Eclipse Java EE IDE for Web Developers (4.7.0)
  • Ubuntu 17.04

Update:

When I check the permission with ls -ltra /opt/tomcat I get that output:

total 124
drwxr-x---  7 tomcat tomcat  4096 Aug  2 23:36 webapps
-rw-r-----  1 tomcat tomcat 15946 Aug  2 23:36 RUNNING.txt
-rw-r-----  1 tomcat tomcat  7064 Aug  2 23:36 RELEASE-NOTES
-rw-r-----  1 tomcat tomcat  1723 Aug  2 23:36 NOTICE
-rw-r-----  1 tomcat tomcat 57092 Aug  2 23:36 LICENSE
drwxr-xr-x  6 root   root    4096 Aug 11 17:56 ..
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 lib
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 bin
drwxr-x---  2 tomcat tomcat  4096 Aug 12 14:53 .oracle_jre_usage
drwxr-xr-x 10 tomcat tomcat  4096 Aug 12 14:53 .
drwxr-x---  3 tomcat tomcat  4096 Aug 12 14:53 work
drwxr-x---  3 tomcat tomcat  4096 Aug 12 15:01 conf
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 temp
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 logs

You really don't want Eclipse and a production installation of Tomcat to mix. The most straightforward thing to do is to download a tarball from http://tomcat.apache.org/ , unpack it, and point the Server -> Runtime Environments preference page at that. This lets you sidestep any file permission issues as long as your make sure that they don't try to use the same ports.

您只需要授予权限

chmod -R 777 /opt/tomcat/

Open the Servers view and add the Tomcat server:

Window > Show View > Servers

In the Server view right click and select

New > Server

Now you'll get a window that looks like the one below. Open the Apache tab and scroll down to Tomcat 8.5 click on it and then click Next.

在Eclipse中添加新服务器

In the next window you will be asked to select resources that are configured on the server. If you don't see any it means you will need to go to your project and add Dynamic Web Module facet. This can be done as follows:

Properties > Project Facets

为项目添加构面

At this point you should be able to start the server and run your project using the controls in the top right of the Servers view, or by right clicking on the specific server. You can add several installations of Jetty, Tomcat, Resin, JBoss, etc if you need them by the way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM