tar -zxvf jdk-10.0.2_linux-x64_bin.tar.gz<\/pre>\n(You can now delete the downloaded tarball)<\/p>\n
Once this has been downloaded and extracted onto your machine, we can use ‘alternatives’ to set up the JDK onto your system without interfering with already existing installs (if present). Use these commands to set up this new version of Java:<\/p>\n
sudo alternatives --install \/usr\/bin\/java java \/opt\/jdk-10.0.2\/bin\/java 2\r\nsudo alternatives --config java<\/pre>\nOnce this is done, you can then set the ‘java’ and ‘javac’ locations using the ‘alternatives’ command.<\/p>\n
sudo alternatives --install \/usr\/bin\/jar jar \/opt\/jdk-10.0.2\/bin\/jar 2\r\nsudo alternatives --install \/usr\/bin\/javac javac \/opt\/jdk-10.0.2\/bin\/javac 2\r\nsudo alternatives --set jar \/opt\/jdk-10.0.2\/bin\/jar\r\nsudo alternatives --set javac \/opt\/jdk-10.0.2\/bin\/javac<\/pre>\nOnce done, you can now check what version of Java is currently active on your system:<\/p>\n
sudo java --version<\/pre>\nThe output should look similar to this:<\/p>\n
java 10.0.2 2018-07-17\r\nJava(TM) SE Runtime Environment 18.3 (build 10.0.2+13)\r\nJava HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)<\/pre>\nWhen this is completed, you will then need to set your environment variables to correspond with the locations of your Java executables. You will need to create new files using your favorite text editor.<\/p>\n
The Bourne Again shell configuration file should be created at the location “\/etc\/profile.d\/java.sh”, and should contain these contents:<\/p>\n
if ! echo ${PATH} | grep -q \/opt\/jdk-10.0.2\/bin ; then\r\n export PATH=\/opt\/jdk-10.0.2\/bin:${PATH}\r\nfi\r\nif ! echo ${PATH} | grep -q \/opt\/jdk-10.0.2\/jre\/bin ; then\r\n export PATH=\/opt\/jdk-10.0.2\/jre\/bin:${PATH}\r\nfi\r\nexport JAVA_HOME=\/opt\/jdk-10.0.2\r\nexport JRE_HOME=\/opt\/jdk-10.0.2\/jre\r\nexport CLASSPATH=.:\/opt\/jdk-10.0.2\/lib\/tools.jar:\/opt\/jdk-10.0.2\/jre\/lib\/rt.jar<\/pre>\nOnce you have entered and saved this in that new file, you can now create a configuration file for the C Shell. This file should be located and named as “\/etc\/profile.d\/java.csh”. The file should contain these contents:<\/p>\n
if ( \"${path}\" !~ *\/opt\/jdk-10.0.2\/bin* ) then\r\n set path = ( \/opt\/jdk-10.0.2\/bin $path )\r\nendif\r\nif ( \"${path}\" !~ *\/opt\/jdk-10.0.2\/jre\/bin* ) then\r\n set path = ( \/opt\/jdk-10.0.2\/jre\/bin $path )\r\nendif\r\nsetenv JAVA_HOME \/opt\/jdk-10.0.2\r\nsetenv JRE_HOME \/opt\/jdk-10.0.2\/jre\r\nsetenv CLASSPATH .:\/opt\/jdk-10.0.2\/lib\/tools.jar:\/opt\/jdk-10.0.2\/jre\/lib\/rt.jar<\/pre>\nYou have now set the environment variables for Java. Make sure to change the file permissions to the correct values:<\/p>\n
sudo chmod 755 \/etc\/profile.d\/java.sh\r\nsudo chmod 755 \/etc\/profile.d\/java.csh<\/pre>\nWe can now continue with the installation of WildFly.<\/p>\n
<\/span>Step 2: Installing WildFly<\/span><\/h2>\nThe first step is downloading and extracting the WildFly software package from WildFly’s website – download the latest version (14.0.1 at the time of writing this tutorial) by using the following command:<\/p>\n
wget\u00a0http:\/\/download.jboss.org\/wildfly\/14.0.1.Final\/wildfly-14.0.1.Final.tar.gz<\/pre>\nOnce the download is finished, you can then extract it by using the next command:<\/p>\n
tar -zxvf\u00a0wildfly-14.0.1.Final.tar.gz<\/pre>\n(You can now delete the downloaded tarball)<\/p>\n
You will now need to set two variables found in the standalone configuration file, found at the location “\/opt\/wildfly-14.0.1.Final\/bin\/standalone.conf”. The two variables set the location of WildFly, and your Java install location. Using your text editor of choice, add these next two lines to that file:<\/p>\n
JBOSS_HOME=\"\/opt\/wildfly-14.0.1.Final\"\r\nJAVA_HOME=\"\/opt\/jdk-10.0.2\"<\/pre>\nOnce this is done, we can now edit the XML configuration file. This file is located at the filepath “\/opt\/wildfly-14.0.1.Final\/standalone\/configuration\/standalone.xml”. Open it with your favorite text editor, and replace all instances of a localhost IP address (they need to be written as “127.0.0.1”) with your server’s public IP address. This will allow us to access WildFly from an external network. Once done, we can now start the server and create our first user.<\/p>\n
Starting WildFly is simple. Just run the executable:<\/p>\n
sudo \/opt\/wildfly-14.0.1.Final\/bin\/standalone.sh<\/pre>\nNow, while this executable will run the server just fine, it will also run inside of your terminal session, meaning that when your session ends, the server will close as well. You can run it in a screen as well by using the “screen” package, but you will still need to start it manually every time your server reboots. To get around this, we created a simple file that will allow you to register WildFly as a service. Just follow these next couple of steps, and you will be able to start and stop WildFly as a regular service, as well as have it run on server boot.<\/p>\n
Create a new file at the location “\/lib\/systemd\/system\/” named ‘wildfly.service’. The full path should be “\/lib\/systemd\/system\/wildfly.service”. Enter the following text into it, and save it.<\/p>\n
[Unit]\r\nDescription=WildFly Server\r\nAfter=httpd.service\r\nStartLimitIntervalSec=0\r\n\r\n[Service]\r\nType=simple\r\nRestart=always\r\nRestartSec=1\r\nUser=root\r\nExecStart=\/opt\/wildfly-14.0.1.Final\/bin\/standalone.sh<\/pre>\nNow, all you need to do is reload the service list:<\/p>\n
systemctl daemon-reload<\/pre>\nAnd you can now start it as a regular service – just run it like any other service:<\/p>\n
systemctl start wildfly.service<\/pre>\nAnd if you wish to enable it so that it runs every time your machine or server boots, that can be done as well:<\/p>\n
systemctl enable wildfly.service<\/pre>\n