如何在 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
How to set java version in JBoss 7?
提问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:
按着这些次序:
Open the "Standalone.conf" file found in your JBoss "bin" folder in a text editor.
Locate the section below:
在文本编辑器中打开 JBoss“bin”文件夹中的“Standalone.conf”文件。
找到以下部分:
# 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"
Edit the last line in the segment above to:
JAVA_HOME="/opt/jdk1.7.0_79/"
Save the standalone.conf file. YOu are good to go
将上面段中的最后一行编辑为:
JAVA_HOME="/opt/jdk1.7.0_79/"
保存 standalone.conf 文件。你已准备好出发
回答by Abdullah Khan
For Window
users @ColithaWa's
answer works
对于Window
用户@ColithaWa's
回答作品
Just edit your JAVA_HOME
key in the jboss/bin/standalone.config
and set it to your wherever your new jdk resides.
只需在 中编辑您的JAVA_HOME
密钥jboss/bin/standalone.config
并将其设置为您的新 jdk 所在的位置。
回答by Shimatsu
- For
Standalone
server orlocaldev
, change filestandalone.conf
- For
domain control
, change filedomain.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"