Tony
Tony

Reputation: 3805

How to set java version in JBoss 7?

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?

Upvotes: 15

Views: 51127

Answers (5)

Shimatsu
Shimatsu

Reputation: 91

  • For Standalone server or localdev, change file standalone.conf
  • For domain control, change file domain.conf

in $JBOSS_HOME/bin

Change the following lines

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

Upvotes: 9

For Window users @ColithaWa's answer works

Just edit your JAVA_HOME key in the jboss/bin/standalone.config and set it to your wherever your new jdk resides.

Upvotes: 0

ColinWa
ColinWa

Reputation: 999

i am using linux and 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.

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

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

Follow these steps:

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

  2. Locate the section below:

# 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"

  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

Upvotes: 0

Stanislav Milev
Stanislav Milev

Reputation: 61

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

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 :)

Upvotes: 5

Niraj Patel
Niraj Patel

Reputation: 2208

To Select alternatives for java

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

[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 more detail

Upvotes: -2

Related Questions