如何配置Tomcat以使用Java 7 ?

时间:2021-12-20 13:27:02

I have a web application in java 6 byte code and would like to test it in a Java 7 JVM environmment. For that purpose, I would like to configure Tomcat (for running the web application) to use Java 7. Now my question is how to do this?

我在java 6字节代码中有一个web应用程序,并希望在java 7 JVM环境中测试它。为此,我想配置Tomcat(用于运行web应用程序)以使用Java 7。现在我的问题是如何做到这一点?

Do I just set my JAVA_HOME environment variable to the path where Java 7 is installed, so that tomcat is run in the right JVM (Version 7)? Or is there another way to do this?

我是否只是将JAVA_HOME环境变量设置为Java 7安装的路径,以便tomcat在正确的JVM中运行(Version 7)?或者还有别的办法吗?

7 个解决方案

#1


3  

You answered your own question.! :) All You need to do is link java 7 in your JAVA_HOME.!

你回答了你自己的问题。你所需要做的就是将java 7链接到JAVA_HOME中。

More Info Here

更多的信息在这里

Edit : (Based on alfabravo's comment :

编辑:(基于alfabravo的评论:

You can definitely change the pointer to JAVA_HOME in your catalina.bat/sh

您可以在您的catalina.bat/sh中更改指向JAVA_HOME的指针。

#2


28  

If you're using Windows, this helps. Run Tomcat helper app (tomcatw.exe) and simply configure Java Virtual Machine DLL path under Java tab. Use default must be unchecked.

如果你在使用Windows,这很有帮助。运行Tomcat助手程序(tomcatw.exe),并在Java选项卡下配置Java虚拟机DLL路径。使用默认值必须不受限制。

如何配置Tomcat以使用Java 7 ?

#3


3  

In Eclipse it is very easy to point Tomcat to a new JVM (in this example JDK7). My problem was I couldn't find where to do it. Here is the trick:

在Eclipse中,很容易将Tomcat指向一个新的JVM(在本例中是JDK7)。我的问题是我找不到做这件事的地方。这是技巧:

  1. On the ECLIPSE top menu FILE pull down tab, select NEW, -->Other
  2. 在ECLIPSE top菜单文件下拉下选项卡,选择NEW, ->Other。
  3. ...on the New Server: Select A Wizard window, select: Server-> Server... click NEXT
  4. …在新服务器上:选择一个向导窗口,选择:Server->服务器…单击NEXT
  5. . on the New Server: Define a New Server window, select Apache> Tomcat 7 Server
  6. 。在新服务器上:定义一个新的服务器窗口,选择Apache> Tomcat 7服务器。
  7. ..now click the line in blue and underlined entitled: Configure Runtime Environments
  8. . .现在,单击蓝色的线并下划线标题为:配置运行时环境。
  9. on the Server Runtime Environments window,
  10. 在服务器运行时环境窗口中,
  11. ..select Apache, expand it(click on the arrow to the left), select TOMCAT v7.0, and click EDIT.
  12. . .选择Apache,展开它(单击左边的箭头),选择TOMCAT v7.0,然后单击EDIT。
  13. you will see a window called EDIT SERVER RUNTIME ENVIRONMENT: TOMCAT SERVER
  14. 您将看到一个名为编辑服务器运行时环境的窗口:TOMCAT服务器。
  15. On this screen there is a pulldown labeled JREs.
  16. 在这个屏幕上有一个拉下标记的JREs。
  17. You should find your JRE listed like JDK1.7.0. If not use the Installed JRE button.
  18. 您应该找到您的JRE列表,如JDK1.7.0。如果不使用安装的JRE按钮。
  19. Select the desired JRE. Click the FINISH button.
  20. 选择所需的JRE。单击FINISH按钮。
  21. Gracefully exit, in the Server: Server Runtime Environments window, click OK
  22. 优雅地退出服务器:服务器运行时环境窗口,单击OK。
  23. in the New Server: Define a new Server window, hit NEXT
  24. 在新服务器中:定义一个新的服务器窗口,点击NEXT。
  25. in the New Server: Add and Remove Window, select apps and install them on the server.
  26. 在新服务器中:添加和删除窗口,选择应用程序并将它们安装到服务器上。
  27. in the New Server: Add and Remove Window, click Finish
  28. 在新服务器中:添加和删除窗口,单击Finish。

Thats all. Interesting, only steps 7-10 seem to matter, and they will change the JRE used on all servers you have previously defined to use TOMCAT v7.0. The rest of the steps are just because I can't find any other way to get to the screen except by defining a new server. Does anyone else know an easier way?

这一切。有趣的是,只有步骤7-10似乎很重要,它们将会更改您之前定义的用于使用TOMCAT v7.0的所有服务器上的JRE。剩下的步骤只是因为除了定义一个新服务器外,我找不到任何其他方法可以到达屏幕。还有其他人知道更简单的方法吗?

TA, Jalkin

助教,Jalkin

#4


2  

I had installed it via

我已经安装好了。

sudo apt-get install tomcat7

Setting up JAVA_HOME or PATH did not help me. I had to add entry in file- /etc/default/tomcat7

设置JAVA_HOME或PATH没有帮助我。我必须在文件- /etc/default/tomcat7中添加条目。

# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat7.
TOMCAT7_USER=tomcat7

# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat7.
TOMCAT7_GROUP=tomcat7

# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.5. If JAVA_HOME is not set, some common directories for 
# OpenJDK, the Sun JDK, and various J2SE 1.5 versions are tried.
#JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
...

This is Java 8 but you get the point.

这是Java 8,但你懂的。

#5


1  

Go to tomcat/bin and modify the JAVA_HOME parmater in catalina.sh (for linux/unix) or catalina.bat (for windows). This means that only tomcat jvm will change, not everything else.

转到tomcat/bin并修改catalina中的JAVA_HOME函数。sh(用于linux/unix)或catalina。蝙蝠(windows)。这意味着只有tomcat jvm会发生变化,而不是其他一切。

#6


1  

If you are using Tomcat inside Eclipse IDE, changing the JRE version for Tomcat is also pretty easy. By default, Tomcat is running under the same JRE as Eclipse (Workbench default JRE). To change JRE version for a Tomcat runtime in Eclipse, go to the menu Window > Preferences. In the Preferences dialog, open the Server > Runtime Environments node, select a Tomcat version in the list, and then click the Edit button: 如何配置Tomcat以使用Java 7 ?

如果您在Eclipse IDE中使用Tomcat,那么更改Tomcat的JRE版本也非常简单。默认情况下,Tomcat在与Eclipse(工作台默认JRE)相同的JRE下运行。要在Eclipse中为Tomcat运行时更改JRE版本,请访问菜单窗口>首选项。在Preferences对话框中,打开服务器>运行时环境节点,在列表中选择Tomcat版本,然后单击Edit按钮:

The Edit Server Runtime Environment dialog appears, select the targeted JRE version under the JRE list:

编辑服务器运行时环境对话框出现,在JRE列表下选择目标JRE版本:

如何配置Tomcat以使用Java 7 ?

for reference see this

看到这个供参考

#7


0  

Tomcat's home page states that

Tomcat的主页声明了这一点。

Tomcat requires a JDK (version 1.6 or later) to be installed. The Sun JDK can be downloaded here.

Tomcat需要安装JDK(1.6版或更高版本)。Sun JDK可以在这里下载。

IMPORTANT: Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the JDK release.

重点:将环境变量JAVA_HOME设置为您安装JDK版本的目录的路径名。

So basically you're correct. Still there might be some compatibility issues. I recommend you read this article for a detailed discussion about Tomcat and Java 7.

所以基本上你是正确的。仍然可能存在一些兼容性问题。我建议您阅读本文以了解关于Tomcat和Java 7的详细讨论。

#1


3  

You answered your own question.! :) All You need to do is link java 7 in your JAVA_HOME.!

你回答了你自己的问题。你所需要做的就是将java 7链接到JAVA_HOME中。

More Info Here

更多的信息在这里

Edit : (Based on alfabravo's comment :

编辑:(基于alfabravo的评论:

You can definitely change the pointer to JAVA_HOME in your catalina.bat/sh

您可以在您的catalina.bat/sh中更改指向JAVA_HOME的指针。

#2


28  

If you're using Windows, this helps. Run Tomcat helper app (tomcatw.exe) and simply configure Java Virtual Machine DLL path under Java tab. Use default must be unchecked.

如果你在使用Windows,这很有帮助。运行Tomcat助手程序(tomcatw.exe),并在Java选项卡下配置Java虚拟机DLL路径。使用默认值必须不受限制。

如何配置Tomcat以使用Java 7 ?

#3


3  

In Eclipse it is very easy to point Tomcat to a new JVM (in this example JDK7). My problem was I couldn't find where to do it. Here is the trick:

在Eclipse中,很容易将Tomcat指向一个新的JVM(在本例中是JDK7)。我的问题是我找不到做这件事的地方。这是技巧:

  1. On the ECLIPSE top menu FILE pull down tab, select NEW, -->Other
  2. 在ECLIPSE top菜单文件下拉下选项卡,选择NEW, ->Other。
  3. ...on the New Server: Select A Wizard window, select: Server-> Server... click NEXT
  4. …在新服务器上:选择一个向导窗口,选择:Server->服务器…单击NEXT
  5. . on the New Server: Define a New Server window, select Apache> Tomcat 7 Server
  6. 。在新服务器上:定义一个新的服务器窗口,选择Apache> Tomcat 7服务器。
  7. ..now click the line in blue and underlined entitled: Configure Runtime Environments
  8. . .现在,单击蓝色的线并下划线标题为:配置运行时环境。
  9. on the Server Runtime Environments window,
  10. 在服务器运行时环境窗口中,
  11. ..select Apache, expand it(click on the arrow to the left), select TOMCAT v7.0, and click EDIT.
  12. . .选择Apache,展开它(单击左边的箭头),选择TOMCAT v7.0,然后单击EDIT。
  13. you will see a window called EDIT SERVER RUNTIME ENVIRONMENT: TOMCAT SERVER
  14. 您将看到一个名为编辑服务器运行时环境的窗口:TOMCAT服务器。
  15. On this screen there is a pulldown labeled JREs.
  16. 在这个屏幕上有一个拉下标记的JREs。
  17. You should find your JRE listed like JDK1.7.0. If not use the Installed JRE button.
  18. 您应该找到您的JRE列表,如JDK1.7.0。如果不使用安装的JRE按钮。
  19. Select the desired JRE. Click the FINISH button.
  20. 选择所需的JRE。单击FINISH按钮。
  21. Gracefully exit, in the Server: Server Runtime Environments window, click OK
  22. 优雅地退出服务器:服务器运行时环境窗口,单击OK。
  23. in the New Server: Define a new Server window, hit NEXT
  24. 在新服务器中:定义一个新的服务器窗口,点击NEXT。
  25. in the New Server: Add and Remove Window, select apps and install them on the server.
  26. 在新服务器中:添加和删除窗口,选择应用程序并将它们安装到服务器上。
  27. in the New Server: Add and Remove Window, click Finish
  28. 在新服务器中:添加和删除窗口,单击Finish。

Thats all. Interesting, only steps 7-10 seem to matter, and they will change the JRE used on all servers you have previously defined to use TOMCAT v7.0. The rest of the steps are just because I can't find any other way to get to the screen except by defining a new server. Does anyone else know an easier way?

这一切。有趣的是,只有步骤7-10似乎很重要,它们将会更改您之前定义的用于使用TOMCAT v7.0的所有服务器上的JRE。剩下的步骤只是因为除了定义一个新服务器外,我找不到任何其他方法可以到达屏幕。还有其他人知道更简单的方法吗?

TA, Jalkin

助教,Jalkin

#4


2  

I had installed it via

我已经安装好了。

sudo apt-get install tomcat7

Setting up JAVA_HOME or PATH did not help me. I had to add entry in file- /etc/default/tomcat7

设置JAVA_HOME或PATH没有帮助我。我必须在文件- /etc/default/tomcat7中添加条目。

# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat7.
TOMCAT7_USER=tomcat7

# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat7.
TOMCAT7_GROUP=tomcat7

# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.5. If JAVA_HOME is not set, some common directories for 
# OpenJDK, the Sun JDK, and various J2SE 1.5 versions are tried.
#JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
...

This is Java 8 but you get the point.

这是Java 8,但你懂的。

#5


1  

Go to tomcat/bin and modify the JAVA_HOME parmater in catalina.sh (for linux/unix) or catalina.bat (for windows). This means that only tomcat jvm will change, not everything else.

转到tomcat/bin并修改catalina中的JAVA_HOME函数。sh(用于linux/unix)或catalina。蝙蝠(windows)。这意味着只有tomcat jvm会发生变化,而不是其他一切。

#6


1  

If you are using Tomcat inside Eclipse IDE, changing the JRE version for Tomcat is also pretty easy. By default, Tomcat is running under the same JRE as Eclipse (Workbench default JRE). To change JRE version for a Tomcat runtime in Eclipse, go to the menu Window > Preferences. In the Preferences dialog, open the Server > Runtime Environments node, select a Tomcat version in the list, and then click the Edit button: 如何配置Tomcat以使用Java 7 ?

如果您在Eclipse IDE中使用Tomcat,那么更改Tomcat的JRE版本也非常简单。默认情况下,Tomcat在与Eclipse(工作台默认JRE)相同的JRE下运行。要在Eclipse中为Tomcat运行时更改JRE版本,请访问菜单窗口>首选项。在Preferences对话框中,打开服务器>运行时环境节点,在列表中选择Tomcat版本,然后单击Edit按钮:

The Edit Server Runtime Environment dialog appears, select the targeted JRE version under the JRE list:

编辑服务器运行时环境对话框出现,在JRE列表下选择目标JRE版本:

如何配置Tomcat以使用Java 7 ?

for reference see this

看到这个供参考

#7


0  

Tomcat's home page states that

Tomcat的主页声明了这一点。

Tomcat requires a JDK (version 1.6 or later) to be installed. The Sun JDK can be downloaded here.

Tomcat需要安装JDK(1.6版或更高版本)。Sun JDK可以在这里下载。

IMPORTANT: Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the JDK release.

重点:将环境变量JAVA_HOME设置为您安装JDK版本的目录的路径名。

So basically you're correct. Still there might be some compatibility issues. I recommend you read this article for a detailed discussion about Tomcat and Java 7.

所以基本上你是正确的。仍然可能存在一些兼容性问题。我建议您阅读本文以了解关于Tomcat和Java 7的详细讨论。