如何在 JBoss 7 中设置 Java 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23339595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 22:04:06  来源:igfitidea点击:

How to set java version in JBoss 7?

javajboss

提问by Tony

I've got machine which is using 2 versions of java(for eg. 6-th and 7-th). If I will run java -version, the system will say it's 6-th. Is there an approach to set another java version for JBoss only?

我有一台机器使用 2 个版本的 java(例如 6-th 和 7-th)。如果我运行java -version,系统会说它是第 6 次。有没有办法只为 JBoss 设置另一个 Java 版本?

回答by niiraj874u

To Select alternatives for java

为java选择替代品

As root, type the following command at the shell prompt and you should see something like this:

以 root 身份在 shell 提示符下键入以下命令,您应该会看到如下所示的内容:

[root@vsr ~]$ /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2           /usr/lib/jvm/jre-1.5.0-sun/bin/java
Enter to keep the current selection[+], or type selection number:

please refer this link for moredetail

请参阅此链接了解更多详情

回答by Stanislav Milev

If you start the jboss from standalone.bat (for .sh find the simmilar lines) you can comment the following lines

如果您从 standalone.bat 启动 jboss(对于 .sh 找到类似的行),您可以注释以下几行

if "x%JAVA_HOME%" == "x" (
  set  JAVA=java
  echo JAVA_HOME is not set. Unexpected results may occur.
  echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
) else (
  set "JAVA=%JAVA_HOME%\bin\java"
)

and add

并添加

set "JAVA=<path to the desired jdk>\bin\java"

That worked for me :)

这对我有用:)

回答by ColinWa

i am using linux and JBoss 7.1.0.

我正在使用 linux 和 JBoss 7.1.0。

i have both JDK 7 and 8. Version 8 is system default JDK so JBoss 7.1 does not not run on JDK 8. I had to use JDK 7.

我有 JDK 7 和 8。版本 8 是系统默认的 JDK,所以 JBoss 7.1 不能在 JDK 8 上运行。我不得不使用 JDK 7。

i installed JDK 7 in the "/opt/" directory.

我在“/opt/”目录中安装了 JDK 7。

Make sure you know the path to your JDK Home, and replace my JDK home with yours.

确保您知道 JDK Home 的路径,并将我的 JDK home 替换为您的。

Follow these steps:

按着这些次序:

  1. Open the "Standalone.conf" file found in your JBoss "bin" folder in a text editor.

  2. Locate the section below:

  1. 在文本编辑器中打开 JBoss“bin”文件夹中的“Standalone.conf”文件。

  2. 找到以下部分:

# Specify the location of the Java home directory. If set then $JAVA will

# be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".

#

#JAVA_HOME="/opt/java/jdk"

# 指定Java主目录的位置。如果设置,则 $JAVA 将

# 定义为 $JAVA_HOME/bin/java,否则 $JAVA 将是 "java"。

#

#JAVA_HOME="/opt/java/jdk"

  1. Edit the last line in the segment above to:

    JAVA_HOME="/opt/jdk1.7.0_79/"

  2. Save the standalone.conf file. YOu are good to go

  1. 将上面段中的最后一行编辑为:

    JAVA_HOME="/opt/jdk1.7.0_79/"

  2. 保存 standalone.conf 文件。你已准备好出发

回答by Abdullah Khan

For Windowusers @ColithaWa'sanswer works

对于Window用户@ColithaWa's回答作品

Just edit your JAVA_HOMEkey in the jboss/bin/standalone.configand set it to your wherever your new jdk resides.

只需在 中编辑您的JAVA_HOME密钥jboss/bin/standalone.config并将其设置为您的新 jdk 所在的位置。

回答by Shimatsu

  • For Standaloneserver or localdev, change file standalone.conf
  • For domain control, change file domain.conf
  • 对于Standalone服务器或localdev,更改文件standalone.conf
  • 对于domain control,更改文件domain.conf

in $JBOSS_HOME/bin

$JBOSS_HOME/bin

Change the following lines

更改以下几行

#JAVA_HOME="/opt/java/jdk" → JAVA_HOME="/path/to/jdk"
#JAVA="" → JAVA="$JAVA_HOME/bin/java"